Importing Rhino Layer Names as List of Numbers in Grasshopper

To try and make processing repetitive 3d topography tasks, bioclimatic analyses, etc, the past few days I managed to put together a nice grasshopper file that automatically models 3d topography into a clean and ‘accurate’ 3d surface using only topographical contours/curves as input (that i manually moved in Rhino vertically before inputing into grasshopper). Not all surveyors are super fun enough to hand in surveys with the topography lines distributed vertically and in neat separate layers, so I was wondering, in order to save time, whether it would be possible to, instead of manually distributing the countours vertically corresponding to their height (usually written in text), whether if I simply left them all on plane 0 but organized them in layers named after their correxsponding height, if then the layer names could be imported into grasshopper as an integer list associated to the curves in the layers to move them all directly by Z in grasshopper by their corresponding layer name (or in this case, height amount), so that the list of layer names (11, 12, 13, 14m… or 0, 5, 10, 15m… etc), would match the list of the curves, then I could connect this directly to the script i have to model the surface and not waste the whole day moving contours up and down manually prior. :sob: :joy:
Let’s imagine the example:

Layer names:
0 (contains 5 curves)
5 (contains 10 curves)
10 (contains 15 curves)
15 (contains 13 curves)
20 (contains 8 curves)
25 (contains 3 curves)
30 (contains 1 curves)

So that the 10 curves in layer 5 would move to height 5 in grasshopper, and so on with the rest of the curves.

Very simplified example Rhino file attached with 10 curves in 10 layers from 1-10meters all at 0.

Example Topography Rhino Layers.3dm (253.7 KB)

I’m using Elefront to reference and filter layers or geometry for Grasshopper.

The benefit over using the geometry pipeline is that you can concatenate layer names in GH for example with a name and a slider.

Elefront | Food4Rhino

Hello Francesco,
here is little c# script to get the layer names and objects.
You can then move the objects in Grasshopper.

ObjectsFromLayers.gh (4.9 KB)

I hope it helps :slight_smile:
Regards,
Max

1 Like

Like magic!! :star_struck: I even tried adding and removing several curves here and there, and disabling/enabling the scirpt component refreshes the input conents of the layers.

Now I have a curious follow-up question (but not essential, in order to prevent cleaning rhino files for use of this script, what you made works great). However, if I had layers I didnt want to use in the script, how could i select the ones I want to use or opt out of using other ones? Since the script itself references all layers rather than individually listed inputs. Maybe with a multiline data panel input to the script component where you’d write the layer names you’d want to use?

you could filter the list with a blacklist, but i think the simpler solution is to put all the layers you want in an other one and choose the parentfolder with the script.
here is a new version. (if you dont put in a parent folder it will pick every layer as before)

ObjectsFromSubfolders.gh (4.9 KB)

2 Likes

Great solution. Hadn’t thought of the parent layer. Thanks Max! Much appreciated.