Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
from .material import handle_materials, material_name
from .layers import handle_layers
from .render_mesh import import_render_mesh
from .curve import import_curve
from .views import handle_views
from .groups import handle_groups
from .instances import import_instance_reference, handle_instance_definitions, populate_instance_definitions
'''
Dictionary mapping between the Rhino file types and importer functions
'''
RHINO_TYPE_TO_IMPORT = {
r3d.ObjectType.Brep : import_render_mesh,
r3d.ObjectType.Extrusion : import_render_mesh,
r3d.ObjectType.Mesh : import_render_mesh,
r3d.ObjectType.Curve : import_curve,
#r3d.ObjectType.InstanceReference : import_instance_reference
}
# TODO: Decouple object data creation from object creation
# and consolidate object-level conversion.
def convert_object(context, ob, name, layer, rhinomat, view_color, scale, options):
"""
Add a new object with given data, link to
collection given by layer
"""