Create a material from python in grasshopper?

Is it possible to create a new material from gh with python. And then apply the material to an object and bake the object with the material applied?

@nathanletwory, I also would like to know this?

It is possible to create a material using RhinoCommon, here a sample in Python.

I suppose you could create one, but note that this would create this in the document.

You’d probably create a component that checks the document if a material already exists, update that one if it does and you want to create something with the same name, or create a new one if it doesn’t. Then I think best is to give that component a string output to which you write the name of your material. That you should be able to connect to the Custom Preview component Material input.

Once you bake from that custom preview component Grasshopper should create a geometry with said material assigned.

Perfect! Thanks!

I was trying the sample you recommend, but there’s no module for:

sc.doc.RenderMaterials.Add

or for

sc.doc.Materials.Add

… any thoughts?? thanks!python

What Rhino version are you using?