Importing Rhino Material files into Rhino using Grasshopper

Hi!

I am making a very simple script that creates layers in Rhino. The idea is to use this instead of a standard Rhino template file, I would like to be able to just click a button in Grasshopper and the layers are created, colors, materials, lineweights, etc. are applied.

The problem is that I can’t find a way to automatically import the Rhino materials from files. I would like it to automatically import everything from a specified folder. I have looked around but I can’t seem to find anything that does exactly this.

This is how far I have gotten with the material import part:

Any help would be much appreciated! :slight_smile:

Hi Jens,
Instead of accesing the command line, you could access the material by layer using rhinoscriptsyntax:
rs.AddMaterialToLayer(layer)
Here is an example add_material_layer.gh (5.3 KB) It works the same with textures and bumps.

Hi David,

Thanks for your help!

It’s not exactly what I’m looking for though, since I would like to use already existing materials from .rmtl files. So I don’t want to define the properties inside Grasshopper, just to import them and apply them to the layers I’m creating in another part of the script. I realize this might not be possible and then your solution is probably the right way to go.

you could still load your mats from .rtml, and then assign them to layers using rs. Maybe this will also help:

Hey David

Sorry for the late reply, I will see if I can make that work and post here if it does.

Thanks for your help :slight_smile:

@jensbuchjohansen did you ever get this to work? Woulf love to get a gh definition if possible.