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
-
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
-
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 -
Thank you very much Mahir. I could not find a way to make that simple operation.0
-
No problem. A lot of what can be done in FS, and CAD in general, boils down to application of vector/matrix/transform math.0
