Get color of subentities when autocolor on in python

Hello,
when we have a body with groups or when exploded (such that we have ‘child’ entities to the original object) and we give the option ‘auto color’ each entity will be colored in a different color.

my question is:
if I have a display object I can turn on the autocolor using object.SetAutoColor(1), when I explode the object into lets say faces, I will get each face with a different color. how can I get the color that each face will get? (I mean from the python script)
as if I do:

Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
[Face_1,Face_2,Face_3,Face_4,Face_5,Face_6] = geompy.ExtractShapes(Box_1, geompy.ShapeType["FACE"], True)
Box_1.SetAutoColor(1)
geompy.addToStudy( Box_1, 'Box_1' )
geompy.addToStudyInFather( Box_1, Face_1, 'Face_1' )
geompy.addToStudyInFather( Box_1, Face_2, 'Face_2' )
geompy.addToStudyInFather( Box_1, Face_3, 'Face_3' )
geompy.addToStudyInFather( Box_1, Face_4, 'Face_4' )
geompy.addToStudyInFather( Box_1, Face_5, 'Face_5' )
geompy.addToStudyInFather( Box_1, Face_6, 'Face_6' )

if I do Face_1.GetColor() (or any of the objects) I will get SALOMEDS.Color(R=-1.0, G=-1.0, B=-1.0) would like to get the RGB values of it.

Hi Franco,

this issue has been fixed in master by our developers. It will be available in 9.14.

Best regards,

Christophe

Hello Christophe,
not even though it was a bug. I thought I was simply doing a wrong workflow, so the script I wrote would correct?

The function SetAutoColor didn’t set the colors themselves. The colors were set when a call to show was triggered.

Your script will work as is.

Christophe

1 Like