How to generate a solid from a set of points

How to generate a solid from a set of points

OldSchoolMakerD
Explorer Explorer
1,068 Views
4 Replies
Message 1 of 5

How to generate a solid from a set of points

OldSchoolMakerD
Explorer
Explorer

Just as a fun exercise, I'm trying to create an icosahedron (the olde 20-sided die problem) in F360 strictly using the API.  I know how to do it using the UI (golden ratio rectangles, joint points into triangle faces, patch, stitch).  I'm trying to get the API to do similar.

 

I compute all the vertices in 3-space - that part's easy.  I then add 2-point lines everywhere -- a little harder, but doable.  But that's about where I run into trouble.  My approach with the UI would have been to select all the faces (triangles) one by one, and Patch.  After that, I can Stitch.  That works on very simple models (e.g., four-sided die / tetrahedron) in the API but fails on the set of points I have for the icosahedron.  I kinda feel like it's joining up things in an odd way when patching, making patch faces cross through the interior of the model.

 

I didn't find any API examples that go from a series of points or lines to a body.  Everything is either about meshes or extrusions, and I'm not doing either.

 

I could potentially break up the model into 20 individual tetrahedrons radiating out from the origin, and then Combine them into one.  But I was hoping for some other approach that could take all the points or faces in one go, and make a single body.

 

Are there better approaches for this?  I'm not too familiar with the "right" ways to build a BRep.

0 Likes
Accepted solutions (1)
1,069 Views
4 Replies
Replies (4)
Message 2 of 5

kandennti
Mentor
Mentor
0 Likes
Message 3 of 5

OldSchoolMakerD
Explorer
Explorer
Interesting. Thanks for the pointer.
The main difference I'm seeing is that I build up a bunch of points and
lines, and then attempt to get them all patched at once. The example given
builds up one "face" (presumably a closed set of 3-space vertices from an
external source) at a time. Each face
- gets its own new sketch
- the sketch points are added and lines are drawn
- the sketch's profiles go into a new collection (per face)
- the profile collection serves as input to a patch operation -- but that's
for a set of patches across all faces
- the patch feature's body is added to the overall collection of surfaces
And when all that is done, it's using a BoundaryFill operation, where I was
using a Stitch.

I'll re-structure my code and try it. Thanks!
0 Likes
Message 4 of 5

Anonymous
Not applicable
Accepted solution

Hi David,

 

I'm sure there is a more efficient way, but my decisions in that code were informed from the following:

- The format of the shape data files.

- There are a wide variety in the types of shapes available, specifically some of the polyhedra have self-intersecting faces.

 

I found that drawing all the lines in a single sketch makes it difficult to automatically detect just the exterior sketch profiles. To avoid having surfaces added in the center of my shape, I only draw one face at a time. 

The boundary fill operation is used instead of patch to properly handle the cases with self-intersecting faces.

0 Likes
Message 5 of 5

OldSchoolMakerD
Explorer
Explorer

Excellent, thanks Evan.  I re-cast my code, effectively unwrapping your "for each face" loop, and it works now!  I still have to get my head wrapped around the concepts -- surfaces -> profiles -> body, etc.  I think your example provides a way of thinking of any arbitrary set of exterior faces forming a body -- and it relies on knowledge of what the exterior faces are.  And that's good enough for what I'm doing, so thanks again.

 

BTW, something additive is happening in your code, so I'll comment on that in the code repo itself, once I figure it out.

0 Likes