Dear All,
I’m trying to find a nice script for return and then print the material name I assigned to a layer . Please can anybody help me? thanks
Something like this should work…
import rhinoscriptsyntax as rs
import scriptcontext as sc
def PrintLayerMaterialName():
#select layer
layer=rs.GetLayer("Select layer to return material name")
if not layer: return
#get materials table, find material index assigned to layer
mat_table=sc.doc.Materials
index=rs.LayerMaterialIndex(layer)
#get material name from material index (-1 means no material)
if index==-1:
print 'Layer "{}" does not have a material asssigned.'.format(layer)
else:
mat_name=mat_table[index].Name
print 'Layer "{}" has material "{}" asssigned.'.format(layer,mat_name)
PrintLayerMaterialName()
–Mitch
1 Like
thanks it works perfectly, I will customize it but it’s really helpful.
thanks again
Thanks!