# Convert Display Color to Render Material?

**URL:** <https://discourse.mcneel.com/t/convert-display-color-to-render-material/146895>\
**Category:** Rendering\
**Tags:** windows\
**Created:** [August 23, 2022, 3:20pm UTC](https://discourse.mcneel.com/t/convert-display-color-to-render-material/146895 "2022-08-23T15:20:13Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![jvm33](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jvm33/32/655276_2.png) [@jvm33](https://discourse.mcneel.com/u/jvm33)\
**Post date:** [August 23, 2022, 3:20pm UTC](https://discourse.mcneel.com/t/convert-display-color-to-render-material/146895/1 "2022-08-23T15:20:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ShynnSup](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/shynnsup/32/767220_2.png) [@ShynnSup](https://discourse.mcneel.com/u/ShynnSup)\
**Post date:** [August 23, 2022, 4:04pm UTC](https://discourse.mcneel.com/t/convert-display-color-to-render-material/146895/2 "2022-08-23T16:04:02Z")

</div>

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.

> **[SynchronizeRenderColors | Rhino 3-D modeling](https://docs.mcneel.com/rhino/5/help/en-us/commands/synchronizerendercolors.htm)**
>
> The SynchronizeRenderColors command changes an object's material color to match its object or layer display color.

---

<div class="post-metadata">

**Author:** ![jvm33](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jvm33/32/655276_2.png) [@jvm33](https://discourse.mcneel.com/u/jvm33)\
**Post date:** [August 23, 2022, 5:13pm UTC](https://discourse.mcneel.com/t/convert-display-color-to-render-material/146895/3 "2022-08-23T17:13:13Z")

</div>

Shynn Sup thank you! Completely forgot about that command.

---

<div class="post-metadata">

**Author:** ![jvm33](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jvm33/32/655276_2.png) [@jvm33](https://discourse.mcneel.com/u/jvm33)\
**Post date:** [August 23, 2022, 6:11pm UTC](https://discourse.mcneel.com/t/convert-display-color-to-render-material/146895/4 "2022-08-23T18:11:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tay.othman](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/tay.othman/32/766134_2.png) [@tay.othman](https://discourse.mcneel.com/u/tay.othman)\
**Post date:** [August 23, 2022, 6:48pm UTC](https://discourse.mcneel.com/t/convert-display-color-to-render-material/146895/5 "2022-08-23T18:48:07Z")

</div>

[Set object color - Scripting - McNeel Forum](https://discourse.mcneel.com/t/set-object-color/29594/3)

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,

---

<div class="post-metadata">

**Author:** ![ShynnSup](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/shynnsup/32/767220_2.png) [@ShynnSup](https://discourse.mcneel.com/u/ShynnSup)\
**Post date:** [August 24, 2022, 12:58am UTC](https://discourse.mcneel.com/t/convert-display-color-to-render-material/146895/6 "2022-08-24T00:58:06Z")

</div>

To get the options you need to type \_

\_SyncrhonizeRenderColors

---

<div class="post-metadata">

**Author:** ![jvm33](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jvm33/32/655276_2.png) [@jvm33](https://discourse.mcneel.com/u/jvm33)\
**Post date:** [August 24, 2022, 11:23am UTC](https://discourse.mcneel.com/t/convert-display-color-to-render-material/146895/7 "2022-08-24T11:23:55Z")

</div>

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](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/5/a/e/5ae5f6028b7360ca6cc47776115e68ad8f462a72.png)

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;  
}

---

<div class="post-metadata">

**Author:** ![nathanletwory](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/nathanletwory/32/482880_2.png) [@nathanletwory](https://discourse.mcneel.com/u/nathanletwory)\
**Post date:** [August 24, 2022, 12:03pm UTC](https://discourse.mcneel.com/t/convert-display-color-to-render-material/146895/8 "2022-08-24T12:03:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ShynnSup](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/shynnsup/32/767220_2.png) [@ShynnSup](https://discourse.mcneel.com/u/ShynnSup)\
**Post date:** [August 24, 2022, 12:37pm UTC](https://discourse.mcneel.com/t/convert-display-color-to-render-material/146895/9 "2022-08-24T12:37:37Z")

</div>

> [@jvm33](#):
>
> script to convert Display color to Material color

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

---

<div class="post-metadata">

**Author:** ![jvm33](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jvm33/32/655276_2.png) [@jvm33](https://discourse.mcneel.com/u/jvm33)\
**Post date:** [August 24, 2022, 1:12pm UTC](https://discourse.mcneel.com/t/convert-display-color-to-render-material/146895/10 "2022-08-24T13:12:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ShynnSup](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/shynnsup/32/767220_2.png) [@ShynnSup](https://discourse.mcneel.com/u/ShynnSup)\
**Post date:** [August 24, 2022, 1:22pm UTC](https://discourse.mcneel.com/t/convert-display-color-to-render-material/146895/11 "2022-08-24T13:22:58Z")

</div>

SynchronizeRenderColors should work fine.

\_SynchronizeRenderColors for options.

---

<div class="post-metadata">

**Author:** ![jvm33](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jvm33/32/655276_2.png) [@jvm33](https://discourse.mcneel.com/u/jvm33)\
**Post date:** [August 24, 2022, 1:51pm UTC](https://discourse.mcneel.com/t/convert-display-color-to-render-material/146895/12 "2022-08-24T13:51:39Z")

</div>

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.

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/3/4/1/341790a3eab99b1ddb8900086cd2b056e55ed5d2.png)

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/a/0/9/a09c7d3523a63e2250584ba0304a95b2f570e252.png)

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/b/b/2/bb298de0351c6b66ed2418b9ee72515cb9c31faa.jpeg)

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

---

<div class="post-metadata">

**Author:** ![ShynnSup](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/shynnsup/32/767220_2.png) [@ShynnSup](https://discourse.mcneel.com/u/ShynnSup)\
**Post date:** [August 24, 2022, 8:10pm UTC](https://discourse.mcneel.com/t/convert-display-color-to-render-material/146895/13 "2022-08-24T20:10:06Z")

</div>

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](https://developer.rhino3d.com/samples/rhinoscript/set-material-colors-from-object-colors/)**
>
> Demonstrates how to modify an object's material color to match its display color using RhinoScript.

[Set Material Colors from Object Colors.rvb](https://discourse.mcneel.com/uploads/short-url/d4sKWWAM1xSRGtHbPWHyFDJvS6n.rvb) (1.5 KB)

To run the script:

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

---

<div class="post-metadata">

**Author:** ![jvm33](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jvm33/32/655276_2.png) [@jvm33](https://discourse.mcneel.com/u/jvm33)\
**Post date:** [August 24, 2022, 11:29pm UTC](https://discourse.mcneel.com/t/convert-display-color-to-render-material/146895/14 "2022-08-24T23:29:06Z")

</div>

Perfect! Thank you, works beautifully.
