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 do I create a Part from a set of vertices/faces in FeatureScript?
greg_frost204
Member Posts: 12 ✭✭
I want to be able to create a solid part from a set of mathematically computed vertices.
I know how to associate the vertices into faces that form a closed volume, but I'm unsure of how best to use feature script to generate the solid.
Fumbling about trying things, I have found that I can generate the points as a set of vectors and organise these into sets that represent triangular faces.
I was able to create surfaces for each face by using opCreateBSplineCurve and opPoint for opposing sides of the triangle and then opLoft to create the flat surface of each face.
At that point I am a bit stuck.
How do I combine all of these surfaces into a solid?
Or is this the complete wrong way to go about this? If so what is a better way?
It seems a bit wrong to be using a spline to create straight lines and a loft to create a flat surface, but it is the best I could manage as a NOOB.
Here is a cut down example of what I have been trying which attempts to create an icosahedron:
https://cad.onshape.com/documents/dc3ef29e02d8dd0f85f142fe/v/2c50a0693a9ca9e82418b66b/e/ec766863895ec061f4d699ef
I know how to associate the vertices into faces that form a closed volume, but I'm unsure of how best to use feature script to generate the solid.
Fumbling about trying things, I have found that I can generate the points as a set of vectors and organise these into sets that represent triangular faces.
I was able to create surfaces for each face by using opCreateBSplineCurve and opPoint for opposing sides of the triangle and then opLoft to create the flat surface of each face.
At that point I am a bit stuck.
How do I combine all of these surfaces into a solid?
Or is this the complete wrong way to go about this? If so what is a better way?
It seems a bit wrong to be using a spline to create straight lines and a loft to create a flat surface, but it is the best I could manage as a NOOB.
Here is a cut down example of what I have been trying which attempts to create an icosahedron:
https://cad.onshape.com/documents/dc3ef29e02d8dd0f85f142fe/v/2c50a0693a9ca9e82418b66b/e/ec766863895ec061f4d699ef
Tagged:
0
Answers
I think the best approach for this would actually be to first create the frame of wires by calling opFitSpline (much simpler interface than opCreateBSplineCurve). You should not need to created the vertices at all. Then, you can create the faces by calling opFillSurface. Finally you can enclose the body with opEnclose (this call is undocumented, but is pretty simple and should be documented, I have put in a request for documentation internally). Here is a simple example:
https://cad.onshape.com/documents/921018298fc434fcad22b76c/w/9863ff2cebe7a9781c07b0d9/e/771201905fa2e41886e59afa
If you are guaranteed that your solids are going to be convex, the problem is somewhat simpler, and you could use opPlane to create infinite planes representing each face, and then use opEnclose to enclose the solid.
You also may want to check out @jon_sorrells' polyhedron feature:
https://cad.onshape.com/documents/2c40f522f1b5a02f6ce9ce01/w/32e0799ad10a8f40ac24abb5/e/c785ef4da2dc45b6c36d0ae7