Created layer not showing in Layers panel after importing mesh?


I possibly found a strange bug. After importing a STL file, I can create a named layer and it will appear in the Layers panel but if I purge all layers and try running the same script again, the layer gets created again (which is good) but is not showing in the Layers panel anymore? Strangely, it also seems to be related to the importation of STL files (and probably other Rhino calls?)

The following script reproduces the problem. (1.2 KB)

I have attached a small .stl file for the test. Any.stl (1.1 KB)

Anybody has an idea of what is going on?


While looking further in the forum, I found this post talking about the Layers panel not refreshing: Bug - Layers Panel Does Not Refresh. I wonder if it could be related to the same problem?

No, the two are not related. I suspect something is up with RhinoCommon’s layer adding function. Give a a few to take a look.

Thank you! Tell me if you find a workaround?

Hi Bruno,

This turned out to be a bug in core Rhino in some slightly used code.

Thanks for reporting.

– Dale

Hello Dale,

Do you know if there is some kind of workaround like calling some other function before or after PurgeLayer?



I don’t know of any workarounds, other than not re-using the same layer name.

A bit of a hack but when you name a layer you can add a random number to the name:

LayerName="Your_Layer_Name_Here" + str(random.randint(0,100000000))

When you rerun the script it should create a unique name for the layer. Not ideal but it works.

Thanks. Not having the different geometries I’m creating on known layers will need more bookkeeping but is doable!