Export Properties to Excel with Layer & Sublayer References

Hi all,

I’ve written a short script to export the areas & centroids of a number of surfaces/polysurfaces to excel in a formatted table - this is currently done with the object names as the reference. Nice and easy…

It would be great to have it formatted so that the layers and sublayers are the references instead, as per the example below. I’ve looked at the available Rhinoscript methods for layers - the layer of the objects can be returned with “ObjectLayer”, but I can’t see a way to file the sublayers under the correct parent layer.

Has anyone done something similar that can point me in the right direction? All help greatly appreciated.

Thanks,
Adam

With Rhinoscript methods, you may need the methods ParentLayer(), LayerChildren() and perhaps LayerChildCount().

ParentLayer() will get you the name of the layer’s parent, if it returns None/Null the layer is a top-level layer.
LayerChildren will get you the names of a layer’s children, None/Null if there are none. That will get you the names and number of immediate children, fine if you have only one level of sublayers. If you have multi-level nesting however, it’s more difficult.

Note that LayerNames() and ObjectLayer() should also return the full layer path:
Layer::Sublayer::SubSubLayer...
You should be able to extract sublayers by spltting the layer names at the "::"

HTH, --Mitch

Thanks Mitch.

How do you go about splitting the strings? Is “Strtok” the correct method using “::” as the delimiter?

You are using (vb) Rhinoscript?

Yes,

split_parts=Rhino.StrTok(your_string,"::")

will work fine, as well as the native vb

split_parts=Split(your_string,"::")

HTH, --Mitch

Yep, Rhinoscript.

Thanks for the pointers