Sorry if this is answered elsewhere but wasn’t able to find it in my searches.
Is the RhinoCommon mesh method, CreateFromBrep:
a. Guaranteed to return as many meshes as there are faces in the brep and if so,
b. Guaranteed to return the meshes in the same order as the faces collection of the brep?
Obviously, trying to figure out which mesh is associated with which face without geometric testing.
The underlying function does iterate the Brep face list in order and mesh each face. So you assumptions should be correct. You should always compare the number of Brep faces with the length of the output array just to be safe.
import Rhino
def test():
filter = Rhino.DocObjects.ObjectType.PolysrfFilter
rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select polysurface", False, filter)
if not objref or rc != Rhino.Commands.Result.Success: return
brep = objref.Brep()
if not brep or 1 == brep.Faces.Count: return
print("Brep face count: {0}".format(brep.Faces.Count))
mp = Rhino.Geometry.MeshingParameters.QualityRenderMesh
meshes = Rhino.Geometry.Mesh.CreateFromBrep(brep, mp)
if meshes:
print("Mesh count: {0}".format(len(meshes)))
if __name__ == "__main__":
test()