Rhino 6.6 GH Python Script Component: Materials table errors

,

Rhino.RhinoDoc.ActiveDoc.Materials[0].Name returns Orange
Rhino.RhinoDoc.ActiveDoc.Materials.Find("Orange", True) returns -1

Materials added programmatically do not appear in the Materials panel, but do increase Rhino.RhinoDoc.ActiveDoc.Materials.Count

Confirmed that code behaves as expected with same file in Rhino 5.

Has anyone else experienced this? Can someone from McNeel replicate to make sure I’m not doing something stupid / missed a change?

-M

Hi @mswaidan,

Please review the following Python sample and let us know if you have any questions.

https://github.com/mcneel/rhino-developer-samples/blob/6/rhinopython/SampleAddRenderMaterials.py

– Dale

Thanks @dale, hadn’t noticed the introduction of RenderMaterial. I’ll rework to accommodate the update.

I still have a question though. How come Materials.Find(“Orange,” True) still returns -1 despite having been added to the document?

E.g. in a vanilla Rhino6 doc., Rhino.RhinoDoc.ActiveDoc.Materials[0].Name returns Plaster, but Rhino.RhinoDoc.ActiveDoc.Materials.Find("Plaster", True) returns -1

Hi @mswaidan,

Yep, this is definitely a bug.

https://mcneel.myjetbrains.com/youtrack/issue/RH-47366

– Dale

RH-47366 is fixed in the latest Service Release

A post was split to a new topic: Material Index -1