Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
Mate Connector Z direction
kevin_aub
Member Posts: 5 ✭
Hi all.
I'm trying to use mate connectors to determine orientation. So in my case I want the wiring direction to be the Z axis of the MateConnector.
I've tried this so far:
I'm trying to use mate connectors to determine orientation. So in my case I want the wiring direction to be the Z axis of the MateConnector.
I've tried this so far:
var cSys is CoordSystem = evMateConnector(context, {
"mateConnector" : definition.startConnector
});
var startOrigin = cSys.origin;
var primaryAxis = cSys.zAxis;
var plane = plane(startOrigin, perpendicularVector(primaryAxis));
var sketch = newSketchOnPlane(context, id + name, {
"sketchPlane" : plane
});
skLineSegment(sketch, "line" ~ name, {
"start" : vector(0, 5) * millimeter,
"end" : vector(0, 0) * millimeter,
});
0
Comments
plane(origin,zaxis,xaxis) will ensure that the plane is in a predictable direction so that you can have the X or Y axis of your sketch correspond to the Z direction.
Another option you have is to use opFitSpline. If you only put two points into a fitspline it comes out as a straight line.
That might get you your result more easily than creating a sketch just to create a line, as you can just put two 3d points in, such as your origin and origin+length*direction.
Custom FeatureScript and Onshape Integrated Applications
or just get the direction with this export function directionTo(fromPoint ,toPoint ) { return normalize(toPoint-fromPoint); }
sorry for the formatting above.