I’ve written a Rhinoscript function that I can call repeatedly to create a standard layer hierarchy. What I want to happen is to identify if the layer already exists, and just skip it in that case. It works the first time I call it PERFECTLY, but if I run it again and the layer I want to create already exists, it fails with an weird error on the Rhino.Addlayer line. I tried adding a Rhino.IsLayerChildOf command just before to see if the layer already exists under the parent, but then that line errors instead. I expected AddLayer to return a null if it fails, but instead it fails in the interpreter. I’d rather not use “On Error”, but I can’t see how to make this work any other way.
strFullLayerTreeName = Rhino.Addlayer(strLayerName, lngColor, True, False, strParentLayerID)