Multiple Manifold Check of a Group

I’m trying to figure out how to determine if a manifold (solid) group is composed of more than one solid bodies.

Once I determine that more than one solid body exists I would like to collect all of the edges of each body into a separate array/list for each body.

An example of where this might come in useful is a situation where some structural subtraction occurs and the remaining ceiling joist or rafter is now actually two pieces:

At this point I am now wanting to know the lengths of each of the two remaining members, which I can do by some logic and checking the longest edge within the manifold/group. However I first need to divide the edges per the solid objects remaining.

Knowing that the outer group is manifold …

# Where ...
ary = group.entities.to_a
pieces = []

# The recursive idea ...
face = ary.find {|e| e.is_a?(Sketchup::Face) }
piece = face.all_connected
pieces << piece
ary = ary - piece
# repeat until ary is empty
2 Likes

… the example does not handle other things like section planes. They would need to be checked for and deleted from ary so that only faces and edges remain. Code defensively.

1 Like

As always, thank-you Dan, I will play around with this a bit more today and post up my results and any additional questions or comments.

1 Like