Get body's color

Get body's color

Anonymous
Not applicable
954 Views
3 Replies
Message 1 of 4

Get body's color

Anonymous
Not applicable

Good day.

 

Is there any common  way to get the color of the body, independent of the material of the body (for all materials except those with textures)?

Now I use this code:

 

properties = body.appearance.appearanceProperties
if properties:
      colorprop = properties.itemById('metal_f0')
      if not colorprop:
            colorprop = properties.itemById('opaque_albedo')
      if not colorprop:
            colorprop = properties.itemById('transparent_color')
      if not colorprop:
             colorprop = properties.itemById('concrete_color')
      if colorprop and colorprop.value:
             r.text = str(colorprop.value.red)
             g.text = str(colorprop.value.green)
             b.text = str(colorprop.value.blue)
             opacity.text = str(colorprop.value.opacity)

But it is rather strange and doesn't work with some materials ("Paint - Metallic", for example).

Does anywhere exist the list of all the properties which are responsible for the color of the body in the UI?

0 Likes
955 Views
3 Replies
Replies (3)
Message 2 of 4

liujac
Alumni
Alumni

Hi,

 

There is no common way to get the color of the body. You can get the colors by appearanceProperties as your code above.

 

Here is the id list of the color properties for your purpose.

"opaque_albedo"

"metal_f0"

"layered_diffuse"

"transparent_color"

"wood_early_color"

0 Likes
Message 3 of 4

Anonymous
Not applicable

Thank you for id list!

0 Likes
Message 4 of 4

Anonymous
Not applicable

Is there any other IDs to get colors, because using this IDs some colors are still missing.

0 Likes