How to use the rhino3dm.ObjectMaterialSource 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
rhinolayer = model.Layers.FindIndex(attr.LayerIndex)

        if not rhinolayer.Visible and not import_hidden_layers:
            continue

        # Create object name
        if attr.Name == "" or attr.Name is None:
            n = str(og.ObjectType).split(".")[1]+" " + str(attr.Id)
        else:
            n = attr.Name
            
        # 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