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.
FeatureScript: How to query (not in viewer!) points and lines to create planes?
leon_poot
Member, Developers Posts: 87 ✭✭✭
I'd like to create a plane in FS using either:
- three points which I create as variables, vector(x,y,z) * meter
- a line (more or less an axis, since it seems infinite) created using line(point,direction) and a point
"A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools." - Douglas Adams, Mostly Harmless
Tagged:
0
Best Answer
-
mahir Member, Developers Posts: 1,309 ✭✭✭✭✭Typically, to create a plane you need an origin and a normal vector. If you created 3 points, you don't need to query anything. You already have vector variables representing those points.
Next, some math. Let's call the points A, B, and C. The origin will be just the average of the 3 points.
origin = (A+B+C)/3
The normal is a little more complicated. You'll need to calculate the cross product of 2 coplaner lines. This can be achieved with the cross command.
normal = cross(C - A, B - A)
Now, you can use the evPlane function.
newPlane = plane(origin, normal)7
Answers
Next, some math. Let's call the points A, B, and C. The origin will be just the average of the 3 points.
origin = (A+B+C)/3
The normal is a little more complicated. You'll need to calculate the cross product of 2 coplaner lines. This can be achieved with the cross command.
normal = cross(C - A, B - A)
Now, you can use the evPlane function.
newPlane = plane(origin, normal)