I was wondering if this was possible native of if there is a script out there that I have missed.
Basically I want to assign material to objects to be per-obeject instead of per-layer, assigning the material of the layer to all objects inside that layer.
import rhinoscriptsyntax as rs
def PerObjectMat():
layers = rs.GetLayers()
if not layers: return
miss = False
for layer in layers:
idx = rs.LayerMaterialIndex(layer)
ids = rs.ObjectsByLayer(layer)
if not ids:
miss = True
continue
for id in ids:
if rs.ObjectMaterialSource(id) == 0:
rs.ObjectMaterialSource(id,1)
rs.ObjectMaterialIndex(id, idx)
if miss:
print("No objects found on some layers")
if __name__ == '__main__':
PerObjectMat()