File3dmMaterialTable Material Duplicates

I am developing a plugin to read a Rhino File. Now I am a bit stuck with the materials, because I dont understand the behavior.

I am getting the materialtable with “File3dm.AllMaterials” but instead of getting the materials of the file like they are in rhino, I get a material per object. So 5 objects with the same material, will result in 5 materials in the materialtable instead of one (what I would have expected)
Is this a wanted behavior? And if so, is there another way to only get those materials once as they are in the material browser? Because it also seems as they are really different objects (different GUID). The only way I see for now is to check via the name of the material.


I think you can get with RenderMaterials Property.

var renderMaterials = doc.RenderMaterials;
var renderMaterialNames = new List<string>();

foreach (var renderMaterial in renderMaterials)
} (5.9 KB)


thanks for looking in to it, but sadly this doesnt apply for the Rhino3dm library. You dont have access to RenderMaterials as far as I can see, like in RhinoCommon.

For now, while generating my own materiallist, I check if the MaterialName already exists and then get the Materialname for the object from the index of the MaterialTable, because the ObjectAttributes only have a MaterialIndex and not a name. It works, but feels like just a workaround…


I’m Sorry.
I’m not very good at English, so I didn’t understand it properly.
It’s not RhinoCommon?

If there is a library other than RhinoCommon that does not have that feature, you may have to remove the duplicate.

The old Materials table is currently the only way to access materials, but unfortunately it isn’t the best way. As you noticed it essentially records material assignments, not materials themselves.

Work was done to get access to RenderMaterials table, but that hasn’t landed in rhino3dm yet - it requires the underlying OpenNURBS be updated to the version in Rhino 8 WIP. But since that is still WIP it will probably be some time before those changes and the added support find their way to rhino3dm (is my guess anyway).

Hi @moritzcramer @nathanletwory
This is a problem I also asked for help on and received none.

Custom Preview component stops displaying in many view modes

Since the fix is a long way off. How do you parse that list to sort out the dups or instances?
Like I said in my post you end up with thousands of materials and worse if you bake out and undo the list fills with nulls. Can’t we get a quick component that filters out the dups as a workaround for now must be doable in Gh python?


Your issue in all likelihood is not related to this topic. I showed how it works for me, but if I can’t reproduce the issue then I can’t help any further. Please continue the discussion related to your issue in your thread.

I understand but I’m asking for help on parsing the materials table.
The reason I mentioned that thread was because I also asked for help on the materials table within that thread.

Don’t use the materials table, use RenderMaterials.

Can you give an example of how that works.
Thanks for your reply,

Thank you for your answer, Nathan. So I’ll stick to the workaround. Maybe a simple improvement of rhino3dm would be the possiblity to get the MaterialName out of the ObjectAttributes. That would simplify the process.

You’ll have to get the material index from the object attributes, then look it up from the materials table.