"::" Layer hierarchy notation doesn't work in rs.GetLayer for "layer" argument

That may be the case - haven’t tested yet - as GetLayer() second argument leads to this:

image

If I’m not mistaken, for it to take into account the full layer hierarchy for this argument, it would have to use

scriptcontext.doc.Layers.FindByFullPath() instead…

Correct me if I’m wrong here…

Not wrong - confirmed.

In a file with a parent layer testB with a child layer testC

import scriptcontext as sc

name="testB::testC"
index_A=sc.doc.Layers.Find(name,True)
index_B=sc.doc.Layers.FindByFullPath(name,True)

print "Layer index: {} | Layer name: {}".format(index_A, sc.doc.Layers[index_A])
print "Layer index: {} | Layer name: {}".format(index_B, sc.doc.Layers[index_B])

Gives:
Layer index: -1 | Layer name: Default
Layer index: 3 | Layer name: testB::testC

Why index -1 “Default”?

image

So be careful, this could actually induce an error…

1 Like