How to use the rhino3dm.ObjectType.InstanceReference 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 / read3dm.py View on Github external
converters.handle_materials(context, model, materials, update_materials)

    # Handle layers
    converters.handle_layers(context, model, toplayer, layerids, materials, update_materials, import_hidden_layers)
    materials[converters.material.DEFAULT_RHINO_MATERIAL] = None

    #build skeletal hierarchy of instance definitions as collections (will be populated by object importer)
    if import_instances:
        converters.handle_instance_definitions(context, model, toplayer, "Instance Definitions") 

    # Handle objects
    for ob in model.Objects:
        og = ob.Geometry

        # Skip unsupported object types early
        if og.ObjectType not in converters.RHINO_TYPE_TO_IMPORT and og.ObjectType != r3d.ObjectType.InstanceReference:
            print("Unsupported object type... ")
            continue

        #convert_rhino_object = converters.RHINO_TYPE_TO_IMPORT[og.ObjectType]
        
        # Check object and layer visibility
        attr = ob.Attributes
        if not attr.Visible and not import_hidden_objects:
            continue

        rhinolayer = model.Layers.FindIndex(attr.LayerIndex)

        if not rhinolayer.Visible and not import_hidden_layers:
            continue

        # Create object name
github jesterKing / import_3dm / import_3dm / converters / __init__.py View on Github external
data = None
    blender_object = None

    if ob.Geometry.ObjectType in RHINO_TYPE_TO_IMPORT:
        data = RHINO_TYPE_TO_IMPORT[ob.Geometry.ObjectType](context, ob, name, scale, options)

    if data:
        data.materials.append(rhinomat)
        blender_object = utils.get_iddata(context.blend_data.objects, ob.Attributes.Id, ob.Attributes.Name, data)
    else:
        blender_object = context.blend_data.objects.new(name+"_Instance", None)
        utils.tag_data(blender_object, ob.Attributes.Id, ob.Attributes.Name)        

    blender_object.color = [x/255. for x in view_color]

    if ob.Geometry.ObjectType == r3d.ObjectType.InstanceReference and options.get("import_instances",False):
        import_instance_reference(context, ob, blender_object, name, scale, options)

    # Import Rhino user strings
    for pair in ob.Attributes.GetUserStrings():
        blender_object[pair[0]] = pair[1]

    for pair in ob.Geometry.GetUserStrings():
        blender_object[pair[0]] = pair[1]

    try:
        layer.objects.link(blender_object)
    except Exception:
        pass