SR12 - Parent Layer Bug?


today I updated to SR12(5.12.50810.13095, 10.08.2015) - 64bit.
Now adding a childlayer under a parent layer using pyhton script does not work any more.

import rhinoscriptsyntax as rs
print “New layer:”, rs.AddLayer(“MyLayer3”)
print “New layer:”, rs.AddLayer(“MyLayer4”,parent=“MyLayer3”)

Above code results in two layers: “MyLayer3” and “MyLayer4” without childs.
Using rhinoscript adding a childlayer still works.
That causes big trouble to me because I have nearly hundred scripts here at work that rely on childlayers…
On another computer yesterday I had the same issue after updating - but now it works again. Don’t know why.
Does anyone have the same problem?
Please help!



I can’t duplicate that and the rs.AddLayer function hasn’t changed between sr11 and sr12.
Do you still have the problem if you run the script on a new file?


Yes the problem still exists after rebooting and running the script in a new document.
It is like the parent keyword is just ignored.

The computer where your script works has the exact same version of Rhino as the one where the script doesn’t work?

Do you mind doing the following 2 things?

  • can you upload the file from the
    C:\Users\%USERPROFILE%\AppData\Roaming\McNeel\Rhinoceros\5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript

  • can you upload the new .3dm file with the 2 layers added?

I’m not sure what I’m looking for … I hope this will give me clues.


Yes it is exactly the same version. But on the other computer it still does not work allways. Sometimes it works on a new file sometimes not. It’s really strange. (12.4 KB)

Sorry for sending twice - fist time I uploaded something.

Update: Now I was also able on my computer to open a document in rhino were adding layers using parent layers does work. But it is still not working on new empty documents.

Can you try to run this script on a new document and paste the output here?

import rhinoscriptsyntax as rs
import scriptcontext

print "New layer: {0}".format(rs.AddLayer("MyLayer3"))

layer_idx = scriptcontext.doc.Layers.FindByFullPath("MyLayer3", True)
if layer_idx >= 0:
    layer = scriptcontext.doc.Layers[layer_idx]
    print "layer name: {0}".format(layer.Name)

print "New layer: {0}".format(rs.AddLayer("MyLayer4",parent="MyLayer3"))


New layer: MyLayer3
layer name: MyLayer3
New layer: MyLayer4

While working I realized, that the behaviour changes from time to time also in an opened document without closing and opening it. So if it works - after a while it does not work any more and vice versa.

Sorry but since I can’t duplicate the problem can you try one more thing? I guess this is not what they mean when they say “remote debugging” :smile:

Can you run this on a new document and post the output?

import rhinoscriptsyntax as rs
import scriptcontext
import Rhino


idx = scriptcontext.doc.Layers.FindByFullPath("MyLayer3", True)
if idx >= 0:
    pl = scriptcontext.doc.Layers[idx]
    print "pl n:{0}, pf:{1}, id:{2}, idx:{3}".format(pl.Name, pl.FullPath, pl.Id, idx)
    nl = Rhino.DocObjects.Layer.GetDefaultLayerProperties()
    nl.ParentLayerId = pl.Id
    nl.Name = "MyLayer4"
    idx = scriptcontext.doc.Layers.Add(nl)
    print "cl n:{0}, fp:{1}, id:{2}, pid:{3}, idx:{4}".format(nl.Name, nl.FullPath, nl.Id, nl.ParentLayerId, idx)
    nl = scriptcontext.doc.Layers[idx]
    print "cl n:{0}, fp:{1}, id:{2}, pid:{3}, idx:{4}".format(nl.Name, nl.FullPath, nl.Id, nl.ParentLayerId, idx)
1 Like

That works! - MyLayer4 is child of MyLayer3

pl n:MyLayer3, pf:MyLayer3, id:d5d9a85d-7f87-4219-8aa9-0b5891da19c0, idx:6
cl n:MyLayer4, fp:MyLayer4, id:00000000-0000-0000-0000-000000000000, pid:d5d9a85d-7f87-4219-8aa9-0b5891da19c0, idx:8
cl n:MyLayer4, fp:MyLayer3::MyLayer4, id:bf5d9af9-e04d-42d6-b23e-32cd1081238f, pid:d5d9a85d-7f87-4219-8aa9-0b5891da19c0, idx:8

First script keeps ignoring wish for parent layer. Output is still:
New layer: MyLayer3
layer name: MyLayer3
New layer: MyLayer4

I think you are quite close - your emulated remote debugging seems to work fine :smile: . Thanks for your great support!

Actually if the original script is failing I was expecting this to fail as well. That failure would have hopefully provided some insight. You said it doesn’t always fail so maybe this was one of the lucky times. It crossed my mind that it might have something to do with running a French version but that seems far fetched. There’s something I’m not seeing …

Yes the two scripts seem to do the same thing. But the second script always works - also if the first one fails. I tried it several times when the first script was not working. The first script keeps failing the second one always does right. I am on a german system - maybe that is important.

Ah German. I thought it was French based on the file you sent. I’ll ponder this problem some more …

btw, I thought it was a stretch to think that the problem was linked to running an non-english version of Rhino but since I don’t see what else could be different I installed a German version of Rhino and I still can’t duplicate the problem.

We are using Windows 7. But I guess you too. On both computers where I updated Rhino to SR12 we got that problem. I stopped updating the 5 remaining computers yesterday because I am afraid it will be same there then. Is there maybe a communication progress between Python/Rhino and something else that could be blocked by a software we have installed? - but I think that would cause an error message.
Is there a way to downgrade to SR11 in case of emergency?
Or maybe I could change the script in so it works the way your second script does - but that seems dangerous to me.

Did you look at on a computer still with SR 11 ?
I had open when Rhino updated to SR12. Then I reopened the file and … had the feeling it was different …
But obviously I can be wrong.
… Just an attempt …

1 Like

On a german system, i get no error using either method, in SR11 and SR12. This may be a shot in the dark, @powerpp does the snippet below work any different ?

import rhinoscriptsyntax as rs
rs.AddLayer(name=“MyLayer4”, parent=“MyLayer3”)



To downgade you need to uninstall the current version and then reinstall the earlier one. Here’s a link to SR11 in German:


Sorry for answering late. I did not have time for testing anything yesterday

Thanks for your input - but problem is still the same

BINGO! the AddLayer definition in has changed significantly.

Replacing by an old one from sr11 solved the problem.

These are the two files: (14.3 KB) (15.3 KB)
But I am still wondering why no one else seems to have the problem.

Thanks all and have a nice day,

Is this bug fixed in Rhinoceros5 SR13 ?