Rhino 7 - GetColor() missing transparency

Hi there! I’ve been using this lovely little script to quickly change the colors of objects:
import rhinoscriptsyntax as rs

    def QuickColour():
        objects = rs.GetObjects("Pick objects for colour change", 0, None, True)
        if objects is None: return
        rs.EnableRedraw(False)
        colour = rs.GetColor(rs.ObjectColor(objects[0]))
        if colour is None:
            rs.UnselectAllObjects()
            rs.EnableRedraw(True)
            return
        else:
            for object in objects:
                rs.ObjectColor(object, colour)
                rs.ObjectPrintColorSource(object, 2) 
        rs.UnselectAllObjects()
        rs.EnableRedraw(True)

    if __name__ == "__main__":     
        QuickColour()`Preformatted text`

The issue is that now the HSL sliders are missing the transparency option:
image

Compared to editing color the “normal” way:
image

Is there any way around this issue?

It appears that rs.GetColor() has not been updated to show the alpha (transparency) channel yet. The Help also hasn’t been adapted to indicate it can get other than RGB colors. In any case it only returns RGB. There may be some RhinoCommon workarounds, I haven’t looked yet.

Edit:
There are a lot of RhinoCommon possibilities to show the color picker.

But the rs.GetColor() method is only using the most basic one that only has the three RGB channels

1 Like

More info:

Looks like there are a lot of rs… methods that are going to need rework for transparency to be supported. rs.ObjectColor() for example also returns an alpha of 255 even when the object has some transparency. And it is getting this info from rhobj.Attributes.ObjectColor.A which also returns 255 no matter if the object has transparency or not.

I filed this to get it on the pile to be looked at:
https://mcneel.myjetbrains.com/youtrack/issue/RH-62364

1 Like