Polysurface - Obtaining sub-objects (surfaces / faces) (Python)

I know how to see the sub-objects (surfaces / faces) after getting a polysurface using Python. I have the GUID of the polysurface. How to I change the color of a sub-object (face / surface)? Are there GUID’s for each sub-object of a polysurface object?

Hi Mike - that is a property on a BrepFace or SubDFace:




Thanks Pascal…

How do I change other object properties such as Layer, Linetype, etc?

A sub-object cannot have a different layer than its parent object. The same thing applies to linetypes, print widths, etc. Brep per-face color is the only thing that is currently allowed to be different as an attribute.

@Helvetosaur - Thanks…I was not aware of that.

@pascal - How do I change the color of an entire object to a custom color (not layer’s color)?

Hi Mike - you need to set the objects’ color source to by object , then set the color:

rs way here:

Is that what you mean?

1 Like

Yes…thank you!

Hi Pascal,

So using PerFaceColor definitely changes the face color, but the face color does not correspond to anything that I have found in the Rhino UI. What is the corresponding property in the Rhino UI for when using PerFaceColor to change the face colors?

For instance…the following shows a group of 4 surfaces where PerFaceColor was applied to the objects. Notice all have a red face affected by the changes implemented by PerFaceColor, the left two have a white border while the right ones have a yellow border.

After PerFaceColor

If I click on the 3rd surface with the yellow border, notice the properties…

The Display Color corresponds to the border color and there is no property that corresponds to the red face that was changed by PerFaceColor.

Any ideas what is the corresponding property in the Rhino UI that PerFaceColor affects? I’ve checked materials, etc as well.

Applying a per face color changes the color of that face, but not the color of the object. So the edges will remain object color.

There is no real UI for per face colors, there is however scripted access to that object attribute.

Ok I figured that. Thanks for the verification!

How do I set PerFaceColor back to Empty?

Face Color: Color [Empty]

FYI PerFaceColor does change the Display Color in the UI for polysurface objects but other objects are not affected.

There is a normal Rhino command for that - RemovePerFaceColors. Are you looking for the scripted implementation?

Not sure what the question is here… I think is is only set up currently to work on multi-face breps (polysurfaces).

Yes I’m looking for the equivalent method to be used in Python. Can you point me in the right direction?

The FYI was not a question, just a comment.

Negate the previous post. Just for other developers viewing this topic, I stepped through rs.CreateColor and found out that it uses the System.Drawing.Color class which has an Empty value so to remove a PerFaceColor, use the following…

PerFaceColor = System.Drawing.Color.Empty

Yes, I would have thought there might be a global attribute for the Brep like HasPerFaceColors that one could set to False to remove the colors, but apparently the only way to remove per face colors from an entire Brep object is to loop through all the faces and if any have a per face color, set them to Empty.

1 Like