Bug in Layer properties

Good afternoon,

I think I found a bug in the latest Rhino 7.6.21127.19001.

Problem

Setting the PlotColor of a Layer instance does not behave as expected

As you can see in this image, the correct layer.PlotColor.Name shoud have been ‘Red’, but it’s returning 'Blue" instead. However, in Rhino 7.3.21039.11201, this problem does not happen.

1 Like

Hi @thomas.takeuchi,

Can you post some code, instead of screen captures, so we can try to repeat?

– Dale

1 Like

Sure @dale!

I was using Rhino 7.6.21127.19001 and Python 3.8.10.

The code was very simple, I was just trying to change some layers properties:

import rhinoinside
rhinoinside.load()

from System.Drawing import Color
from Rhino.DocObjects import Layer

layer = Layer()
layer.Color = Color.Blue
layer.Name = 'Layer'
layer.PlotColor = Color.Red
layer.LinetypeIndex = 2
layer.PlotWeight = 0.18

assert layer.PlotColor.Name == 'Red'

To me, this assertion returns False as it says layer.PlotColor.Name == ‘Blue’ for some strange reason.
If I follow te same code in Rhino 7.3.21039.11201, the assertion returns True

Hey @thomas.takeuchi,

Colors in .NET are not quite the same as color on openNURBS, which is what the Rhino3dm.py is based on. Our ON_Color class defines alpha=0 as opaque, and System.Drawing.Color defines alpha=255.

The code appears to be doing the alpha conversion. So I’m not quite sure what is going on. So I’ve logged the issue so we can look into this.

https://mcneel.myjetbrains.com/youtrack/issue/RH-64633

– Dale

1 Like

Thank you for taking a look at it @dale !