How to use the rhino3dm.MeshType.Any function in rhino3dm

To help you get started, we’ve selected a few rhino3dm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jesterKing / import_3dm / import_3dm / converters / render_mesh.py View on Github external
def import_render_mesh(context, ob, name, scale, options):
    # concatenate all meshes from all (brep) faces,
    # adjust vertex indices for faces accordingly
    # first get all render meshes
    og = ob.Geometry
    oa = ob.Attributes

    if og.ObjectType == r3d.ObjectType.Extrusion:
        msh = [og.GetMesh(r3d.MeshType.Any)]
    elif og.ObjectType == r3d.ObjectType.Mesh:
        msh = [og]
    elif og.ObjectType == r3d.ObjectType.Brep:
        msh = [og.Faces[f].GetMesh(r3d.MeshType.Any) for f in range(len(og.Faces)) if type(og.Faces[f])!=list]
    fidx = 0
    faces = []
    vertices = []
    # now add all faces and vertices to the main lists
    for m in msh:
        if not m:
            continue
        faces.extend([list(map(lambda x: x + fidx, m.Faces[f])) for f in range(len(m.Faces))])

        # Rhino always uses 4 values to describe faces, which can lead to
        # invalid faces in Blender. Tris will have a duplicate index for the 4th
        # value.
github mcneel / rhino3dm / docs / python / samples / getmeshes.py View on Github external
# Sample read render meshes from 3dm file
import rhino3dm
model = rhino3dm.File3dm.Read('mymodel.3dm')
brep = model.Objects[0].Geometry
face = brep.Faces[0]
mesh = face.GetMesh(rhino3dm.MeshType.Any)
print (len(mesh.Faces))
github jesterKing / import_3dm / import_3dm.py View on Github external
rhinomatname = rhinolayer.Name + "+" + str(layeruuid)
        if matname:
            rhinomat = materials[matname]
        else:
            rhinomat = materials[rhinomatname]
        layer = layerids[str(layeruuid)][1]

        # concatenate all meshes from all (brep) faces,
        # adjust vertex indices for faces accordingly
        # first get all render meshes
        if og.ObjectType==r3d.ObjectType.Extrusion:
            msh = [og.GetMesh(r3d.MeshType.Any)]
        elif og.ObjectType==r3d.ObjectType.Mesh:
            msh = [og]
        elif og.ObjectType==r3d.ObjectType.Brep:
            msh = [og.Faces[f].GetMesh(r3d.MeshType.Any) for f in range(len(og.Faces)) if type(og.Faces[f])!=list]
        else:
            continue
        fidx=0
        faces = []
        vertices = []
        # now add all faces and vertices to the main lists
        for m in msh:
            if not m: continue
            faces.extend([list(map(lambda x: x + fidx, m.Faces[f])) for f in range(len(m.Faces))])
            fidx = fidx + len(m.Vertices)
            vertices.extend([(m.Vertices[v].X, m.Vertices[v].Y, m.Vertices[v].Z) for v in range(len(m.Vertices))])
        # done, now add object to blender
        add_object(context, n, attr.Name, attr.Id, vertices, faces, layer, rhinomat)

    # finally link in the container collection (top layer) into the main
    # scene collection.