C#: Modifying LayerIndex for RhinoObject doesn't change Layer - Why not? [Solved]

I have some existing Rhino objects which I want to move to another Layer, but why is the following code not moving the RhinoObjects into the new Layer specified by the index?

for (var i = 0; i < rhinoObjects.Length; i++)
    RhinoObject rhobj = rhinoObjects[i];
    rhobj.Attributes.LayerIndex = layer_index;  // No change :(

OK, adding CommitChanges(); does the trick:

    rhobj.Attributes.LayerIndex = layer_index;

// Rolf

1 Like