Programmatically move layer to top of layertable in RhinoCommon

Hi there,

this might (again) be a rather stupid question…
What if I wanted to move a layer to the top of the LayerTable?
It happens quite sometimes that I have to add the Default Layer or at least have to move it up to the table again to obtain a proper model (pedantic, but I can’t help myself).

I can find ways to set an index of a layer, but it does not change in the layertable.
Any ideas?


IfI remember correctly, you cannot.

I always start a layer name with a number. That is the best work around to the best of my kmowledge.


I fully agree, this is what I usually do as well.
But sometimes you receive messed up models or accidents may happen and for this reason I try to prep myself.

Ya, there is no way to programatically reorder/recover the order of the layers. I searched this topic long time ago, but simply there is no API exposed to C#. Perhaps Rhino native plugins can do but I’m not sure.

Hi @mikity_kogekoge and @tobias.stoltmann, it is possible control layer sorting by using some kind of workaround where you add other layers or childlayers to a temporary parent layer and then back to the original parentlayer or the root of layers, leaving the one layer you do want to “move on top” at the first place.

I’ve done this to partially sort using layerstructures which where not sortable with the build in method of the Layers panel (By clicking on the Name column header).

The initial thread for this workaround was here, @Jarek also posted a rvb script here.



@clement @mikity_kogekoge

Without properly understanding the script here:

A thought that came to mind now is… why not trying to access the layerpanel and the control displaying the layertree?

I might give this a try, but maybe that’s not even possible?

Hi @tobias.stoltmann, there is no way yet to access the layer’s panel and perform the sorting. It would be helpful though to define some display order for root level or sub layers within a parent layer programmatically without doing the mentioned workaround. (Which is computationally intensive with large layer structures).


@clement okay, understood.

Dear @dale, i’m tagging you here since you’re working on the layer panel…

Wish: (Get/Set) layer.SortIndex

…with ability to set index per root level or depending on the parent layer, eg. something like this would make a root level layer the first layer in the layers panel:

layer.SortIndex = 0;

if layer has a parent layer, it would make it the first child. Possible ?


1 Like

Hi @clement, @tobias.stoltmann,

A wish to control the sort order of layers is on the heap.

– Dale