import Rhino
for layer in Rhino.RhinoDoc.ActiveDoc.Layers:
name = layer.Name+'_M'
material_id = Rhino.RhinoDoc.ActiveDoc.Materials.Find(name,True)
if material_id == -1:
material = Rhino.DocObjects.Material()
material.Name = name
material_id=Rhino.RhinoDoc.ActiveDoc.Materials.Add(material)
layer.RenderMaterialIndex=material_id
#coding=utf-8
import rhinoscriptsyntax as rs
objs = rs.GetObjects("")
if objs:
for obj in objs:
layer = rs.ObjectLayer(obj)
rs.LayerMaterialName(index,ObjectName+"_m")
#coding=utf-8
import rhinoscriptsyntax as rs
objs = rs.GetObjects("")
if objs:
for obj in objs:
layer = rs.ObjectLayer(obj)
rs.ObjectName(obj, layer)
index = rs.LayerMaterialIndex(obj)
if index>-1:
ObjectName = rs.ObjectName(obj)
rs.LayerMaterialIndex(index, ObjectName+"_m")