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.
How do you get individual axes from a mate connector in featurescript?
HuguesLessardWRI
Member Posts: 14 PRO
As part of my featurescript, I would need to rotate a mate connector around one of its axis to reorient it. For instance, how do I get the vector representing the X-axis of a mate connector? I have used the evMateConnector, but I do not see how to extract only one of the vector.
0
Best Answers
-
EvanReese Member, Mentor Posts: 2,191 ✭✭✭✭✭@HuguesLessardWRI
to add on to Neil's answer. evMateConnector gets you the CoordSystem, which is a map that contains the origin, zAxis, and xAxis. To get at the stuff inside a map, you use dot notation and the name of the thing you want from the map. I did something similar recently and it looked like this:<div> var myMateConnector = definition.myMateConnector; </div><div> var mateCoord = evMateConnector(context, { </div><div> "mateConnector" : myMateConnector </div><div> }); </div><div> var origin = mateCoord.origin;</div><div> var zDirection = mateCoord.zAxis;</div><div> var xDirection = mateCoord.xAxis;</div><div> var yDirection = yAxis(mateCoord);</div>
Evan Reese1 -
NeilCooke Moderator, Onshape Employees Posts: 5,723This will do it:
precondition { annotation { "Name" : "Mate Connector", "Filter" : BodyType.MATE_CONNECTOR, "MaxNumberOfPicks" : 1 } definition.mc is Query; annotation { "Name" : "Angle" } isAngle(definition.angle, ANGLE_360_BOUNDS); } { var mc = evMateConnector(context, { "mateConnector" : definition.mc }); opTransform(context, id + "transform1", { "bodies" : qOwnerBody(definition.mc), "transform" : rotationAround(line(mc.origin, mc.xAxis), definition.angle) }); });
Senior Director, Technical Services, EMEA1
Answers
https://cad.onshape.com/FsDoc/library.html#CoordSystem
to add on to Neil's answer. evMateConnector gets you the CoordSystem, which is a map that contains the origin, zAxis, and xAxis. To get at the stuff inside a map, you use dot notation and the name of the thing you want from the map. I did something similar recently and it looked like this: