Layer.ComponentStatus

Hi @dale,

i am trying to find out if a layer is highlighted (selected) in the Layers dialog. There is a layer.ComponentStatus having IsHighlighted and IsSelected properties, both seem to return False regardless of the selection state:

layer.ComponentStatus.IsHighlighted
layer.ComponentStatus.IsSelected

however if i call other properties like hidden or locked like this:

layer.ComponentStatus.IsHidden
layer.ComponentStatus.IsLocked

the returned booleans show what is present in the Layers dialog. Can you explain how to work (Get, Set) with the ComponentStatus of a layer in python ?

btw. RhinoScriptSyntax is missing Rhino.SelectedLayers method.

thanks,
c.

This is the magic:

https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_DocObjects_Tables_LayerTable_GetSelected.htm

– Dale

Thanks @dale. I should have explained a bit why i need this as individual property:

I am working on a custom dialog which is similar to the built in Layer dialog but also displays objects and some of their properties. This dialog should run in sync with Rhino’s built in Layer dialog. Therefore i am trying to query if a layer is current, hidden, locked, selected, unselected, deleted, undeleted, renamed etc. Some of these properties can be queried on a per layer basis, some using events (adding, renaming, deleting, sorting, attribute changes etc.), some others are simply not available.

Tracking changes made in the built in layer dialog might be accomplished by using layer events, which alone turns out to be a large project as events are fired multiple times for a single operation. Tracking changes in my dialog is done using my own events.

All tracking runs recursive and special caution is required to prevent event bubbling. After working on this project for a while i realized this is a huge task and there are required bits missing in the API eg:

A method to get & set the selection state on a per layer basis (how to unselect ?)
An event which gets fired if the layer selection changes.

Since layers are mostly accessable index based, i realized that changing the layer order in the built in Layer dialog is problematic. Eg. scriptcontext.doc.Layers does not return the layers in the display order, so i need to sort using layer.SortIndex to stay in sync with that. All these hurdles require a lot of iteration which i have to do in both dialogs after every change to keep both dialog contents visually in sync. But all of this only makes sense if i can notice changes made in both dialogs.

Back to my inital question, is layer.ComponentStatus a way to get and set the selection and why does it return a “Clear” state when the layer is selected ?

_
c.

Hi @clement,

A layer does not have a “selected in user interface” state. But you can use LayerTable.GetSelected and LayerTable.Select to select items in the layer panel (Windows only).

No, a layer inherts from ModelComponent, but it does not use ModelComponent.ComponentStatus. Perhaps it will some day.

– Dale

Thanks @dale, i guess i need to rearrange things a bit for now. Having the layer selection state as an event in the future would be useful.

_
c.