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 to mirror a part using a plane?
Lee_Hesketh
Member, Developers Posts: 148 ✭✭✭
I tried calling mirror, but there was no option to select entities or a mirror plane. Which function do I have to call to do this?
There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!
Tagged:
0
Best Answers
-
Jake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646Try something like this:
mirror(context, id + "mirror1", { "patternType" : MirrorType.PART, "entities" : someQueryForEntities, "mirrorPlane" : someQueryForTheMirrorPlane });
Mirror is an Onshape Feature rather than an operation (operations start with the 'op' prefix). This means that the FeatureScript Code of Mirror directly drives the Feature Dialog you get when you click the 'Mirror' button in the UI. This means that for a mirror plane you must actually use a Query for some construction plane or a planar face of a solid or a sketch (not just a Plane object). If you are confused about how to use an Onshape Feature in Featurescript, check out the public document called 'std'. This is the Onshape Standard FeatureScript library. If you go to the tab called mirror.fs you can see the source code of mirror, and read through the 'precondition' to see what the definition map (the third parameter of the function call) requires.Jake Rosenfeld - Modeling Team5 -
Jake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646There are two options here:
1 (easier): Use 'opPlane' to create a construction plane from your plane() and then get that construction plane with qCreatedBy(planeId, EntityType.FACE) as the mirror plane. You will want to then use deleteBodies on qCreatedBy(planeId, EntityType.BODY) if you want that plane to disappear from your part studio.
2 (unnecessarily hard): Copy the mirror code into your file as a helper function and change the precondition and body to take a Plane rather than a Query.Jake Rosenfeld - Modeling Team5
Answers
Mirror is an Onshape Feature rather than an operation (operations start with the 'op' prefix). This means that the FeatureScript Code of Mirror directly drives the Feature Dialog you get when you click the 'Mirror' button in the UI. This means that for a mirror plane you must actually use a Query for some construction plane or a planar face of a solid or a sketch (not just a Plane object). If you are confused about how to use an Onshape Feature in Featurescript, check out the public document called 'std'. This is the Onshape Standard FeatureScript library. If you go to the tab called mirror.fs you can see the source code of mirror, and read through the 'precondition' to see what the definition map (the third parameter of the function call) requires.
1 (easier): Use 'opPlane' to create a construction plane from your plane() and then get that construction plane with qCreatedBy(planeId, EntityType.FACE) as the mirror plane. You will want to then use deleteBodies on qCreatedBy(planeId, EntityType.BODY) if you want that plane to disappear from your part studio.
2 (unnecessarily hard): Copy the mirror code into your file as a helper function and change the precondition and body to take a Plane rather than a Query.