LayerTable Event OldState FullPath incorrect

When making a C# plugin for Rhino, our Command subscribes to RhinoDoc.LayerTableEvent to react when a user moves a layer from a certain place into another. To accomplish this, we need to read the OldState and the NewState’s FullPaths to determine the previous and target Parentage of the moved Layer. Unfortunately, OldState appears to represent a parent-less state: FullPath is just Name, and ParentId = guid.Empty. This makes it impossible to know the true original position in the Layer hierarchy.

In the sample scenario screenshotted below, I’m moving a layer from under ParentLayer2 to under ParentLayer1.
1_LayerPanel


Variations of this issue have been noted in 2017 and 2019, but with different scripting goals that were able to be worked around, and no true explanations or solutions were provided. As you can see from the script’s intended functionality above, there is no clean workaround in this case, so I wanted to resurrect the issue to understand if this is intentional behavior on Rhino’s part, or if this can be considered a bug that should be addressed.

Thanks so much!

Hi @andrew_chittenden,

FullPath isn’t really a property of Layer. It’s only presented as one for convenience. It’s value is always resolved as needed.

The property you want to watch for is ParentId. When a layer is re-parented, this is the value that is changed.

– Dale

1 Like

Thanks! I’m not sure why in some earlier tests ParentId was always turning up as guid.Empty even when it wasn’t, but this works now, and I’m able to use it to manually resolve the OldState FullPath string.