I am trying to avoid that a user locks a layer in a Rhino plugin written using Rhinocommon. When the plugin is initialized, an event handler is coupled to the LayerTableEvent using
RhinoDoc.LayerTableEvent += this.OnLayerEvent;
The event handler is defined as
public void OnLayerEvent(object sender, Rhino.DocObjects.Tables.LayerTableEventArgs e)
{
if (e.NewState.IsLocked)
{
e.Document.Layers[e.LayerIndex].IsLocked = false;
e.Document.Layers[e.LayerIndex].CommitChanges();
}
}
The event is triggered when a lock in the Rhino layers panel is clicked and the if
condition evaluates to true
if the layer gets locked (a breakpoint inside the if
statement is reached). However, after the event, the layer remains locked. Is it possible that e.Document.Layers[e.LayerIndex].IsLocked = false;
does not lock a layer. Or am I missing something else here?