It seems rs.GetLayer doesn’t respect layer hierarchy so strings with “::” in them are not recognized as a valid layer names.
rs.GetLayer("Select Layers", layer='Plans::Text')
Can anyone confirm?
It seems rs.GetLayer doesn’t respect layer hierarchy so strings with “::” in them are not recognized as a valid layer names.
rs.GetLayer("Select Layers", layer='Plans::Text')
Can anyone confirm?
That may be the case - haven’t tested yet - as GetLayer() second argument leads to this:
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”?
So be careful, this could actually induce an error…
Thank you for the research @Helvetosaur. I will fallback to Rhino.UI for now. I guess this should be filed as a BUG.
In the worst case, while waiting, you could simply encapsulate the GetLayer definition in your script - just copy the code out of userinterface.py and paste it in to your script as a separate definition - then modify the appropriate code line as above…
@Alain - can this be “improved”?
Already did that. Thank you.
Thanks for looking into that Mitch.
The issue is fixed in 6.x.
Ha…
** **
Thanks Alain!