I want to use Grasshopper to do some stuff to Rhino-produced pipe solids. It looks like the DeBrep faces are ordered: 0 lengthwise tube, 1 start cap, 2 end cap. But can I rely on that? If not, how can I determine which face is which?
I don’t know in advance how the pipes are capped (i.e. flat, round or none). I won’t have any original centrelines or other construction geometry.
Sorry if this is an irritatingly newbie question, but that’s where I’m at!
Jeremy
As a rule, you should not rely on the order. This is especially true if you have modeled your geometry in Rhino, or if you have performed unpredictable operations like a boolean union or difference.
However! It is generally reasonable to rely on the face order of geometry generated in grasshopper in a consistent way. The “pipe” component will almost certainly preserve the same face order (at least for a given cap style.) So a pipe with flat caps will probably always have the same face order.
If you cannot rely on the construction mechanism, then you have to analyze your faces to find out which is which. I commonly use any of the following techniques to identify which face is the face I want:
Sort by area
Sort by proximity to a known point or other object
Sort by surface normal as compared to some known axis (with a Dot Product or similar)
Sort by Edge count
Sort by Surface Curvature value
Is it reasonable to assume that the caps are going to be smaller in area than the pipe sides (i.e. no very short pipes)? If this is the case I would do something like this:
Deconstruct the Breps
Sort faces by area
Extract the largest face (this is likely to be the side/tube of the pipe)
If any additional faces remain, these are likely to be the caps. If you need to distinguish between flat / round, you can analyze curvature or something else to distinguish.
Thanks for the suggestions. I was surprised at how tricky a problem this is. Unfortunately the pipes will have originated in Rhino, not Grasshopper. And I can’t make any advance assumptions about length v. diameter, or about position or orientation. And the tubes will probably not be straight.
I think its time to dust off pad and paper and produce scenarios for each type of end cap, then see if I can use the topology component to classify the pipes in each scenario.