rs.ObjectColor() always returns A (transparency) value as 255

I believe I reported this a long, long time ago, but rs.ObjectColor() still always returns 255 (fully opaque) for the A value of a color, even if it is not…

Run the following scriptlet on an object that has some transparency value applied to its display color:

import rhinoscriptsyntax as rs

obj_id=rs.GetObject("Select object to analyze",preselect=True)
if obj_id:
    print "R={} G={} B={} A={}".format(color.R,color.G,color.B,color.A)

A will always come up as 255.
This is the case with both V7 and the current WIP…

And this despite that the rhinoobject attributes does report the correct A values:

Below for reference is a file with 4 surfaces with differing degrees of transparence. They all come up with the same values using the script.
4xTransp.3dm (2.0 MB)

Happy to see that at least rs.LayerColor() does report the correct A value.

To add to that, apparently rs.ObjectColor() calls ObjectAttributes.DrawColor() under the hood, which is sadly undocumented, so there is no way to know what it exactly does. At least the behavior of rs.ObjectColor() -while undesireble- is consistent with it’s documentation, as an RGB color carries no transparency information, compared to an RGBA color:

Returns of modifies the color of an object. Object colors are represented
as RGB colors. An RGB color specifies the relative intensity of red, green,
and blue to cause a specific color to be displayed

I agree with @Helvetosaur that now that transparency is used more throughout rhino, the api should properly reflect that

By the way @dale, there is this YouTrack item which is marked as closed…

Maybe incorrectly?

@Helvetosaur - the issue you reference relates to RhinoScript. This is a RhinoCommon issue.

– Dale

RH-72572 is fixed in Rhino 7 Service Release 28 Release Candidate