RhinoScript return all children of a layer?

Is there a method to return ALL children of a given layer? I have a model in which I have several levels of nested children layers and would like to operate on them all.

I guess it wouldn’t be too much of a headache to write a function to extract the childen layer names of any layer with a child count, but thought there might be a built in method I’m missing.

Thanks for any insight

https://developer.rhino3d.com/api/rhinocommon/rhino.docobjects.layer/getchildren

Does this help?

– Dale

Does RhinoScript use RhinoCommon? I might be a bit behind the times.

Hi @anon,

The original RhinoScript (VBScript) is written in C++ and pre-dates RhinoCommon.

The rhinoscriptsyntax library is written in Python and uses RhinoCommon. The purpose of the library is to help those migrating from RhinoScript to Python. But some use it for convenience.

Of course, you can use RhinoCommon with Python without using rhinoscriptsyntax.

— Dale

I know this a dumb thing to confirm, but just to be clear: that means rhinoscriptsyntax, using RhinoCommon, is unavailable in the original VBScript RhinoScript, correct?

Hi @anon,

That is correct - legacy RhinoScript cannot call into RhinoCommon.

If you need a layer’s children from RhinoScript, use Rhino.LayerChildren.

– Dale

Hi @anon,

There is no built in method in RhinoScript that would return ALL children. The method that Dale refers to would return a list of the immediate children only (no grandchildren, etc.).

Not too much but depends how flexible you want it to be for input/output. Here is one way to do it:
z_Function_Return_ALL_Layer_Children.rvb (1.1 KB)

1 Like

That’s it @Jarek, nice one.