How to use the rhino3dm.ObjectColorSource.ColorFromLayer 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
# Get render material
        mat_index = ob.Attributes.MaterialIndex

        if ob.Attributes.MaterialSource == r3d.ObjectMaterialSource.MaterialFromLayer:
            mat_index = rhinolayer.RenderMaterialIndex

        rhino_material = model.Materials.FindIndex(mat_index)

        # Handle default material and fetch associated Blender material
        if rhino_material.Name == "":
            matname = converters.material.DEFAULT_RHINO_MATERIAL
        else:
            matname = converters.material_name(rhino_material)

        # Handle object view color
        if ob.Attributes.ColorSource == r3d.ObjectColorSource.ColorFromLayer:
            view_color = rhinolayer.Color
        else:
            view_color = ob.Attributes.ObjectColor

        rhinomat = materials[matname]

        # Fetch layer
        layer = layerids[str(rhinolayer.Id)][1]

        
        if og.ObjectType==r3d.ObjectType.InstanceReference and import_instances:
            n = model.InstanceDefinitions.FindId(og.ParentIdefId).Name

        # Convert object
        converters.convert_object(context, ob, n, layer, rhinomat, view_color, scale, options)