ifcopenshell.api.style.edit_surface_style

Module Contents

class ifcopenshell.api.style.edit_surface_style.Usecase
edit_colour_or_factor(name, value)
edit_colour_rgb(name, value: dict)
edit_specular_highlight(value)
execute()
ifcopenshell.api.style.edit_surface_style.edit_surface_style(file: ifcopenshell.file, style: ifcopenshell.entity_instance, attributes: dict[str, Any]) None

Edits the attributes of an IfcPresentationItem

For more information about the attributes and data types of an IfcPresentationItem, consult the IFC documentation.

The IfcPresentationItem is expected to be one of IfcSurfaceStyleShading, IfcSurfaceStyleRendering, IfcSurfaceStyleWithTextures, IfcSurfaceStyleLighting, IfcSurfaceStyleReflectance, or IfcExternallyDefinedSurfaceStyle.

To represent a colour, a nested dictionary should be used. See the example below.

Parameters:
  • style (ifcopenshell.entity_instance) – The IfcPresentationStyle entity you want to edit

  • attributes (dict) – a dictionary of attribute names and values.

Returns:

None

Return type:

None

Example:

# Create a new surface style
style = ifcopenshell.api.style.add_style(model)

# Create a blank rendering style.
rendering = ifcopenshell.api.style.add_surface_style(model,
    style=style, ifc_class="IfcSurfaceStyleRendering")

# Edit the attributes of the rendering style.
ifcopenshell.api.style.edit_surface_style(model,
    style=rendering, attributes={
        # A surface colour and transparency is still supplied for
        # viewport display only. This will supersede the shading
        # presentation item.
        "SurfaceColour": { "Name": None, "Red": 1.0, "Green": 0.8, "Blue": 0.8 },
        "Transparency": 0., # 0 is opaque, 1 is transparent

        # NOTDEFINED is assumed to be a PHYSICAL (PBR) lighting
        # model. In IFC4X3, you may choose PHYSICAL directly.
        "ReflectanceMethod": "NOTDEFINED",

        # For PBR shading, you may specify these parameters:
        "DiffuseColour": { "Name": None, "Red": 0.9, "Green": 0.8, "Blue": 0.8 },
        "SpecularColour": 0.1, # Metallic factor
        "SpecularHighlight": {"SpecularRoughness": 0.5}, # Roughness factor
    })