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 :(
    ...
}

EDIT:
OK, adding CommitChanges(); does the trick:

    rhobj.Attributes.LayerIndex = layer_index;
    rhobj.CommitChanges();

// Rolf

2 Likes