RenderMaterials is empty on open obj with material

Hello all
I’m interested in grapping the materials from the RenderMaterial table. This works fine except when I open f.ex. an obj file with a mtl file added. The material attached to the object i visible in the Material GUI, but the RenderMaterial table returns 0 count. It does not appear until I f.ex. choose the type in the dropdown type menu and reassign “custom”, then it suddenly springs to life. Is the RenderMaterial not properly initialized upon opening even though visible in the GUI? How can I get access to it without doing the trick of reassigning type.
Thank you very much!

If you attach a simple file we can have a look.

Thank you Nathan
Here is a simple obj file with mtl and texture. It’s difficult for me to send the script because it’s part of a larger, but accessing RenderMaterials.count after opening of the file gives 0 unless I reassign type via GUI or recreate material. It might be that I misunderstand how rendermaterial operates in general.

Edit: Also listening on Rhino.RhinoDoc.MaterialTableEvent fires 3 times when reassigning type the first time hereafter only once per material change. Not so important for me, but I thought I would mention it.


When I import the .obj file you shared I see a Rhino Custom material added to the materials editor. The following script gives the expected information:

import scriptcontext as sc


for rm in sc.doc.RenderMaterials:


<Rhino.Render.NativeRenderMaterial object at 0x000000000000002D [Rhino.Render.NativeRenderMaterial]>

What Rhino version are you using? I tested with Rhino 7.

Thank you again @nathanletwory , I should of course have tested the raw functionality to exclude issues in my overall code. On my side I’m accessing the table from a Grasshopper component, but that should not be a problem.
However I have just tested with the latest Rhino 7, that I just got, and it works as expected, but on Rhino 6.26.20147.***, that I’ve been building and testing against, I get the error as described.

That is actually 8 service releases behind, perhaps time to update to the latest?. That said, the latest SR also shows this problem. I’ve logged this as


Yes - this is a new feature of Rhino 7. All “old school” materials are converted to RenderMaterials on all import and open operations.

In Rhino 6, you must also check the document RhinoDoc.Materials table - it’s painful, I know.

  • Andy

@andy, importing the file shows the material as Custom in my Rhino 6.34 - not the same?

Yes, I know. I’ve been building for older versions because I have clients that are not always updating their software to the latest version. Definitely time to upgrade. Thank you very much for your help Nathan!

Thank you Andy, that explains it. I will implement it for my Rhino 6 version.