Change surface color retrieved from GetObject

Hello,

I am currently trying to change the color of selected surfaces with GetObject.
When the object is exploded, there is no problem, my code works, but as long as different surfaces are joined, it colors the whole object.

I’ve used this loop to color the object, and I understand that selecting the RhinoObject is the problem, but I couldn’t find a way to change the color of a BrepFace or simply a Surface (go is my GetObject object).

for (int i = 0; i < go.ObjectCount; i++) {
    ObjRef objRef = go.Object(i);
    RhinoObject obj = objRef.Object();
                
    RhinoDoc doc = obj.Document;
    obj.Attributes.ObjectColor = System.Drawing.Color.FromArgb(color.ToArgb());
    obj.Attributes.ColorSource = ObjectColorSource.ColorFromObject;
    obj.CommitChanges();

    doc.Views.Redraw();
}

I am able to retrieve the BrepFace with objRef.Face() and the Surface from the BrepObject but I can’t find any method or attribute that can help me. Any ideas?

Thank you for your answers,
Thomas.

Do you want to change the color of a face in a brep/poysurface to a different color than the rest of the brep/polysurface? That is not possible as far as I am aware.

Yes that’s what I am trying to do.
And is it possible to do it with materials?

Hi @thomas.vincent,

In Rhino 7, you will be able to set individual face colors for a polysurface.

This feature is fairly new in the Rhino WIP, so I don’t have an API that I can reference for you.

In Rhino 6, you can assign individual render materials to a polysurface. Although this feature has been in Rhino 6 for a while, the API was just exposed in the future Rhino 6 SR26.

– Dale