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 use mirrorAcross
papawo
Member, Developers Posts: 206 PRO
Best Answer
-
Jake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646You can mirror across any planar face, so if the part you're mirroring has a good face for that, you can just use that face.
Otherwise, if you have the mathematical description for the plane you want to mirror across, but no actual geometry for it, you can do something like:var mPlane = plane(vector(1, 2, 3) * inch, vector(1, 0, 0)); // <-- just an example, use any plane you want opPlane(context, id + "plane", { "plane" : mPlane }); // <-- creates the construction plane<br>mirror(...); // <-- do the mirror using qCreatedBy(id + "plane", EntityType.FACE) as the `mirrorPlane` opDeleteBodies(context, id + "delete", { "entities" : qCreatedBy(id + "plane", EntityType.BODY) }); // <-- delete the plane so it is not left behind in the Part Studio
https://cad.onshape.com/FsDoc/library.html#plane-Vector-Vector
https://cad.onshape.com/FsDoc/library.html#opPlane-Context-Id-map
https://cad.onshape.com/FsDoc/library.html#opDeleteBodies-Context-Id-map
Jake Rosenfeld - Modeling Team6
Answers
Calling mirrorAcross returns a 'Transform' which can be used in a variety of ways. A few examples: a transform could be used in applyPattern() to mirror a part or it can be multiplied by a world space 'Vector' to mirror that vector across the plane in question.
https://cad.onshape.com/FsDoc/library.html#module-transform.fs
The concept is similar to a transformation matrix in linear algebra:
https://en.wikipedia.org/wiki/Transformation_matrix
If you don't want to boolean the result onto the seed, you can just leave out the last 3 parameters.
how to create or get that plane without user selecting the face?
Otherwise, if you have the mathematical description for the plane you want to mirror across, but no actual geometry for it, you can do something like:
https://cad.onshape.com/FsDoc/library.html#plane-Vector-Vector
https://cad.onshape.com/FsDoc/library.html#opPlane-Context-Id-map
https://cad.onshape.com/FsDoc/library.html#opDeleteBodies-Context-Id-map