Convert Display Color to Render Material?

There are some really nice scripts that can randomize and interpolate display colors for shaded mode. Is it possible to convert display colors to Rhino 7 materials?

Thanks!

jvm

Yes, there is a command for it.

Select your objects and type:

SynchronizeRenderColors

It will create a material with the color of the later I believe.

3 Likes

Shynn Sup thank you! Completely forgot about that command.

SynchronizeRenderColors – this command does not convert an objects display color to a render material – converts an object to a layer color. Don’t see any further options for this command.

Set object color - Scripting - McNeel Forum

You probably need to use some python script, assuming one material per object. If you have too many object you will end up with a huge amount of materials in the file which may cause a problem.

I think you can use the script as a starting point,

To get the options you need to type _

_SyncrhonizeRenderColors

1 Like

Here’s an older python script to convert Display color to Material color – not sure who made it, but it doesn’t seem to work in V7 – this is the exception message I get when running.

image

Here’s the script.

public DisplayMaterial CreateDisplayMaterial(
string filename,
double alpha,
Color color,
double shine,
double transparency
)
{
var material = new DisplayMaterial
{
Diffuse = color,
IsTwoSided = false,
Shine = shine,
Specular = Color.White,
Transparency = transparency
};

// Set the environment map
material.SetEnvironmentTexture(filename, true);

// Tweak the environment map
var texture = material.GetEnvironmentTexture(true);
if (null != texture)
{
texture.TextureCombineMode = TextureCombineMode.Blend;
double constant, a0, a1, a2, a3;
texture.GetAlphaBlendValues(out constant, out a0, out a1, out a2, out a3);
texture.SetAlphaBlendValues(alpha, a0, a1, a2, a3);
}

return material;
}

That is because the code is not Python but C#.

I am not sure I am following, that is exactly what the command does, no need for a script.

Ah! Thanks Nathan, obviously not familiar with python and c# code. The file I have has a .py extension, so wrongly assumed it was phython.

Shynn Sup, are you saying the command is _So_SynchronizeRenderColors?

Thanks

SynchronizeRenderColors should work fine.

_SynchronizeRenderColors for options.

Thanks Shynn Sup – the command does work, just not what I’m trying to do, unless I’m missing something. The _SynchronizeRenderColors uses the layer color (which can be different than object color) for rendering. I can use _SetObjectDisplayMode on the 150 objects to display shaded when I render which is a work around – it doesn’t work if I’m tyring to render with raytrace.

What I’d like to do is take all 150 objects which are all on the same layer and which I’ve run a progressive color script to create unique display colors, convert the display color to a render material, which uses the display color for the material color.

Thanks again,

jvm

I see, the command does work for Object display color, but each object needs to be in a separate layer.

I found the script you need here. (VB language)

Set Material Colors from Object Colors.rvb (1.5 KB)

To run the script:

Command: Loadscript/ Then select the file I just attached.
Command: Runscript

Perfect! Thank you, works beautifully.