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 create an offset plan in a feature script ?
Antoine_Bodin
Member Posts: 6 PRO
Hello there,
I am currently trying to create a plane that is offset from the original. How can I do it in a script ?
I am currently trying to create a plane that is offset from the original. How can I do it in a script ?
Tagged:
0
Best Answer
-
mahir Member, Developers Posts: 1,309 ✭✭✭✭✭You just have to do some simple vector math. Every plane has an origin and a normal vector. The code for creating a plane2 offset by 1in from plane1 is as follows.
//create plane2 as a copy of plane1 var plane2 = plane1;<br> //shift plane2's location along it's normal plane2.origin += plane2.normal*1in;
Since the planes are facing the same direction, the normal doesn't have to change. If you want to offset in the opposite direction, use -= instead of +=. Those two commands (along with *= and /=) are shorthand for a = a +-*/ b. Now, for getting the original plane itself, that depends on your specific application. You're likely either selecting it via query and using evPlane, or generating it with opPlane. It's up to you. Hope that helps.6
Answers
Since the planes are facing the same direction, the normal doesn't have to change. If you want to offset in the opposite direction, use -= instead of +=. Those two commands (along with *= and /=) are shorthand for a = a +-*/ b. Now, for getting the original plane itself, that depends on your specific application. You're likely either selecting it via query and using evPlane, or generating it with opPlane. It's up to you. Hope that helps.