How can I get the bottom surface of a selected geometry?
Thank you
How can I get the bottom surface of a selected geometry?
Thank you
Extrusion.ToBrep()
will always put the caps at the end of the created Brepâs faces list, if they exist:
Undocumented behavior (subject to change) is that the exact order of that list is [profile0_srf, profile1_srf, ..., bottom_cap, top_cap]
. If the extrusion is not capped at one end, the surface is not added to the Brep (so the bottom cap can be the last face in the Brep if there is no top cap). You should add a test to select the cap you want (from the last two surfaces of the Brep) rather than rely on this specific order between bottom and top cap, but as a first approximation it might be good enough.
Extrusion.IsCappedAtBottom/Top
will tell you if there is a bottom/top cap.
I guess that this is also dependent on what you consider âbottomâ. If an extrusion is done from a closed curve from the Front viewport/CPlane, for example, the caps will not be the âtopâ and âbottomâ faces relative to the World coordinate system.
For brep objects that I expect to have at least one planar surface at the 'bottom" relative to a particular coordinate system, I always do a bounding box in that coordinate system, get the bottom plane of the box and see if any of the brep faces lie in that plane (which is easy to test).
Absolutely, and I should have defined what I called âbottomâ. In my message, the bottom cap is the one at the start of extrusion path, the top cap the one at the end of the extrusion path. If the extrusion is along a path oriented along +\vec{z}, then âtopâ and âbottomâ should match the worldâs definition of âtopâ and âbottomâ.
The test that @Helvetosaur mentions is a good one and you should implement it if you care about your scriptâs robustness.