Rhino8 - Layer adding with python script (RESOLVED)

Hi all,

Quite some time ago I wrote a RhinoPython script to add a block of layers in Rhino5.
It creates a series of new layers with succeeding numbers following a prefix based on a selected sub layer, and the new layers will be classed as child layers to the common parent layer.

I upgraded recently to Rhino8, and the parent layer seems to be ignored, as the new layers appear as primary layers. Other than that it works fine.

These are the relevant script lines, where “layername” is the selected child layer:

parentbaselayer=rs.ParentLayer(layername)
rs.AddLayer(newname,color=layercolor,parent=parentbaselayer)

Could this be a bug?

Max.

RESOLVED, see below

Maybe instead of

rs.AddLayer(newname,color=layercolor,parent=parentbaselayer)

try:

rs.AddLayer(newname,color=layercolor,parent=layername)

Thanks Adam, but it does not do what I want it to do. Your variation creates new “grand childs” under the child layer I selected, and I want extra childs under the same parent.

BUT: once I reinstated the original script the problem seems to have gone away, I must have done something wrong initially…

Max.