Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
model = None
try:
model = r3d.File3dm.Read(filepath)
except:
print("Failed to import .3dm model: {}".format(filepath))
return {'CANCELLED'}
top_collection_name = os.path.splitext(os.path.basename(filepath))[0]
if top_collection_name in context.blend_data.collections.keys():
toplayer = context.blend_data.collections[top_collection_name]
else:
toplayer = context.blend_data.collections.new(name=top_collection_name)
# Get proper scale for conversion
scale = r3d.UnitSystem.UnitScale(model.Settings.ModelUnitSystem, r3d.UnitSystem.Meters) / context.scene.unit_settings.scale_length
layerids = {}
materials = {}
# Parse options
import_views = options.get("import_views", False)
import_named_views = options.get("import_named_views", False)
import_hidden_objects = options.get("import_hidden_objects", False)
import_hidden_layers = options.get("import_hidden_layers", False)
import_groups = options.get("import_groups", False)
import_nested_groups = options.get("import_nested_groups", False)
import_instances = options.get("import_instances",False)
update_materials = options.get("update_materials", False)
# Import Views and NamedViews