Converting an RGB Swatch to a Material in Rhino?

Hi All,
Hoping for some guidance i assumed would be quite straight forward - but I’m not having a lot of luck!

I have a grasshopper script where i want to bake out some objects - and I want them to be the same colour in either rendered or shaded view.

Is it possible to use an RGB colour from a colour gradient - and use that to produce a material in Rhino which is then baked in when the objects are baked?

I will be using a remote bake for this, such that i have a button in my control panel that does the baking from 6-7 different streams.

Thanks in advance!
Xmall

Hi,
here’s a small script I’ve used in the past for this. Utilising Human and Elefront Legacy plugins.
This is old, but I think you can get the logic from this.


Create Material from Colour.gh (41.5 KB)

The idea is that your read all the object colours (R,G,B), and create matching materials, with diffuce channel and name (“R,G,B”). Assigning colours is with gate, as otherwise the process of simultaneously creating and assigning materials is very slow with a large set.

I assume this could be heavily improved with current Rhino version.

1 Like

Here’s how you can do this with Rhino 8 or 9:

It would be slightly different with blocks.

cache-material-object.gh (14.9 KB)

1 Like

@Toni_Osterlund @martinsiegrist
Thank you for the prompt reply and solutions.

That is indeed very close to what i was after. @martinsiegrist one drawback I noted was that results display correctly in rendered view - but does not have the same colour assigned in shaded etc.

Is it possible to bake out such that it includes both the general colour, and material (i.e. looks the same for both rendered or shaded)?

Thanks again.
Xmall.

Have found the solution to the above query,
I note by expanding the variable parameters we get a Display Attributes input, allowing us to pass the RGB for the display attribute as well as the material.

Also noted the Content Cache also allows input of a remote trigger so this is perfect for my needs.

Marked up below for anyone looking to do the same in future:

Thanks once more for the help!
Xmall

1 Like