Assign Layer Materials

Assigns render materials to layers and auto-populates connected Value Lists.

Utilities Nickname: LAYERMAT

Overview

Assigns render materials to layers and auto-populates connected Value Lists.

Inputs (3)

  • LayerNames (Text): Layer names or paths. Connect a Value List here!
  • UseFullPath (Boolean): If True, material name = 'Parent::Child'. If False, just 'Child'.
  • RunScript (Boolean): Connect a Button/Toggle to execute.

Outputs (4)

  • Instructions_Out (Text): Component interface documentation.
  • LogOutput (Text): Persistent execution log.
  • UpdatedCount (Integer): Number of layers that received a new material.
  • SkippedCount (Integer): Number of layers that already had a material.

Method, assumptions and simplifications

The same notes appear in the component's Info output.

Method

  1. When RunScript is True, each layer in LayerNames (found by full path, else by short name; all layers if empty) that has no render material gets one.
  2. The material is named after the layer full path (UseFullPath True) or short name; an existing material with that name is reused.
  3. A new material takes the layer colour as diffuse colour, transparency = 1 - alpha / 255, white specular and shine 30.
  4. Before each solve, a Value List wired to LayerNames is refilled with all document layers (name shown, full path as value) when the layer list changes.

Assumptions

  • Layer colours carry the intended material colour.

Simplifications and limits

  • Layers that already have a material are skipped and never updated, even if the layer colour changed.
  • Creates basic legacy Rhino materials, not physically based ones. In short-name mode, layers with the same name share one material.