Rhino3dm Layer Visibility

Hi All,

I was using the Visible property of a Rhino3dm layer object and I observed that the child layer remains visible even if the parent layer is off.
visibility_1
From the image above, the Visible property of the grid layer is False. However, for the child layers it is True.

If I select the child layers and manually turn them off then only the Visible property works as expected. Is this a planned behaviour? Is there a workaround on Rhino3dm side?

@stevebaer, is this something you can respond to?

@dale, it looks like Visible (i.e. IsVisible in Rhinocommon-speak) and GetPersistentVisibility() are returning the same value for a layer, regardless of the visibility of the layer itself and its parent(s). Is this the expected behaviour?

1 Like

Hi @Devang_Chauhan, @will - there is a pretty good description of Layer. GetPersistentVisibility here:

Does this help?

– Dale

Thanks @dale. I think the description of Layer.GetPersistentVisility() is pretty clear, but I’m still unclear on the intended behaviour of Layer.IsVisible. Should IsVisible property match what happens in Rhino?

For example, if a layer is marked as visible but its parent is not then I’d expect IsVisible to return false (and GetPersistentVisibility() would return true). What am I missing?

@dale,
Thanks for pointing that out. I was aware of the persistent visibility setting. I never tried it and I am not very clear on how to use that on child layers. This setting is for what happens to the child layers when the parent layer is turned on. But under the hood the Visible property of the child layer remains True. Which is not what I expect.

Can you share a sample of how this settings work. Do we just do layer.SetPersistentVisibility(False)?

Hi @Devang_Chauhan,

Rhino’s layer table tries to ensure the validity of layers and their many settings. But it is certainly possible to create and/or modify layers incorrectly.

Do you have a sample 3dm file and some source code that produces layers that don’t seem to work correctly?

– Dale

Hi @dale,

I am using a blank rhino file with the following layer structure
layer status

import rhino3dm

path = r"C:\Users\devan\Desktop\test.3dm"
rhino3dm_file = rhino3dm.File3dm.Read(path)

for layer in rhino3dm_file.Layers:
    print(layer.Name, layer.Visible, layer.GetPersistentVisibility())

Output

Default False False
Layer 01 True True
Layer 02 True True
Layer 03 True True

I would expect the Visible property to be False for Layer 01 and Layer 02.

If you had any objects on Layer 01 or Layer 02, those objects will not be visible on the rhino canvas. However, as you can see in the output, the Visible property for those layers is True. This behavior is confusing. Is it planned?

Hi @Devang_Chauhan,

I can verify that what you describe is how Rhino writes 3dm files.

Certainly this reports differently when run in Rhino:

import scriptcontext as sc

for layer in sc.doc.Layers:
    print(layer.Name, layer.IsVisible, layer.GetPersistentVisibility())

– Dale

1 Like