How to get the layer materials in Rhino, along with the custom materials?

Hi !

Rhino stores its materials in a material table, and I have iterated the material table to get the materials, but the problem is that I can’t get the layer materials from it. I can only get the custom materials.

How do I get the references to the layer materials and the object that is using them?

Thanks!

Hi @alexian007,

You can obtain a layer’s render material index using ON_Layer::RenderMaterialIndex().

To retrieve all of the objects that are on a layer, use CRhinoDoc::LookupObject.

ON_SimpleArray<CRhinoObject*> layer_objects;
int count = context.m_doc.LookupObject(layer_index, layer_objects);

– Dale

1 Like

Thanks dale!