Can objects carry informations about more than one list?

So my question is, if it is possible to have objects (points, curves, breps… what ever) that can belong to more than one list with different tree structures? Or more precise that they have a kind of class through which i can navigate to them.

To make the question more clear I made a quite simple example.
It is just an array of points in x and y direction with 10 steps.

So there is one tree structure which is splitting in 10 branches making rows in the direction of the y axis.

And then there is an other tree structure (made by closest point in this case) spliting the list of points in different sized ‘groups’ (represented by different colours here).

In this example these two tree structures represent two different lists of objects. So if I would pick one point and move it, it would only change it’s coordinates in one of the lists, in the other it would stay same. So I would have to perform all “transformations” double.

Is it somehow possible to have an object, that carries two or three or even more path informations (or “properties”)? For example in this case the information, that it belongs to ‘row’ 3 and also to ‘group’ 10 and if I change something (as the position), the coordinates would change in both lists.

So can I assign information to objects (as ‘row’ 3 or ‘group’ 10), through which i navigate to them to perform further actions?

GH1 has no metadata, but you don’t need it because you can organize it your metadata preserving the order of the geometry, so that each index (a tree path + a list index or whatever) links to a specific geometry and a specific metadata.

If the question is related with queries (simple/nested the likes of PLINQ or LINQ) then you’ll need a custom class (say: an “info class”) related with the object(s) properties that you want to query/cluster (the properties can be any imaginable info derived from the object in question: type, topology data, connectivity data, relations, memory usage etc etc).

For instance: from a GeometryBase collection find items that are either Meshes or Breps, that yield a valid Volume, that have at least 23 BrepFaces/MeshFaces, each of them has at least N neighbors, each of them has at least an A Area, where each edge has at least a L Length … blah, blah. Just imagine any combo of “questions” and get the gist of the approach.

This type of stuff is used in clusterig (hard, soft , HAC) and in object equality clustering as well (but equality on non primitives is a chimera).

First of all, thank you both for the answers!

Well if I get it correctly, yes it links to queries, that is basically what I want to achieve. Also that these properties of object(s) can change under certain conditions.
(Unfortunately) my knowledge of scripting is small and of general informatics even smaller, but how I understood it, for my case I need to define, what you call a custom class (or an “info class”), that I can run these queries and work with clusters.
But then of course the next question is following: Can I do that in the graphic grasshopper-node environment? Or do I need to do that (at least partly) in C#?
Does maybe someone know an addon or something similiar which lets me define metadata and work with clusters in the graphic GH environment?

Well … I could provide an indicative C# demo on that puzzle of yours IF you can explicitly list an imaginery collection of queries (i.e. given a collection of things (a) I want this, this and that, (b) I want this … etc etc). That’s very easy to do mind (if you know how to code). The bad news are that you wouldn’t be able to change anything in order to make other queries for other cases etc etc (unless this could act as the ignition point for learning how to code).

You can set UserText manually in Rhino or with Grasshopper, my preferred method is the Elefront plugin. Then filter the attributes to create various trees.

1 Like

So the thing is I don’t have a direct task I need a special query for. It is more that I am planning on something and realized that a data structure where I could give objects several attributes and search them by these is something that would in that context ease many things a lot.

I already suspected somehow that to achieve that I should start to learn coding and I had a look at some tutorials for C# in grasshopper. But I thought maybe there is a way directly in grasshopper that I am just not aware of.

If you would provide a C# demo which is assigning additional attributes to objects from grasshopper and then run an easy query (maybe like in the example all points from ‘row’ 3 belonging to ‘group’ 10) that would be very helpful for me, just to have a starting point to understand how to work with that.
If the question is to general, of course also advice on tutorials/documentation relating to that is very welcome!

I will also definetely have a look into that, thank you!

To have:


is equivalent to have:

0. Object1
1. Object2


    0. Property1
    1. Property2
    2. Property3
    0. Property1
    1. Property2
    2. Property3

And even you can have all with flat list rather that datatrees. The point is, all structure can be flattened into list or tables without information loss, you just need the connectivity rules. If you knew how to program I wouldn’t suggest doing this, but doing it at GH is your best option in my opinion.

OK: I have at least 500 C# things that do “that kind” of stuff … so the challenge is to find some “entry level”/tutorial cases as a kind of quideline for your future coding adventures.

PS: I assume that you fully know what a DataTree is (kinda a dictionary of Lists … and NOT a List of List of List … blah, blah).

Update: Found some easy stuff (about 20) :

For start walking a very long (and hilly) walk, get the attached: has some primitive queries via a custom class related with some object properties BUT the big thing is the “transfer” of a custom class List from one C# to another This obvioulsy is rather critical in real-life defs … blah, blah.

So misleadingly the C#'s name is after that big thing.

PS: I NEVER internalize things other than primitives (so load R file first for the demo stuff).

CastClass_EntryLevel_V2.3dm (354.8 KB) (121.6 KB)

Get this as well: (9.9 KB)

And this that measures(?) the cost of flying from DC to NY via LA: (117.1 KB)

Next case: Buildings in planet Zorg with random build year, height, volume, footprint area, Zorgian cats and dogs: how to find where a cat lives, when paid last time some taxes and how to cluster the bad dogs.

You think so? Although under the hood it’s a SortedList< GH_Path, List< T> > (which implements IDictionary), it’s not used as a dictionary by default, but as a (sorted) list of lists. Just as in a list you have the elements indexed, the branches are indexed as well. Paths (GH_Path) are indexers, more than keys (or at least the indexing version of a key), because the implementation of the datatree sacrifices the freedom given by keys in a dictionary to preserve an indexed order, what other use are they? Although you can store a list with a unique key/path to retrieve it later, how many times do you use it like this the datatrees compared to having only ordered lists? That’s why I don’t think it’s convenient to give more mystery/complexity to the data tree when explaining it to newbies.

Er … hmm … I said … kinda.

(unless this could act as the ignition point for learning how to code).

Actually it was back then. Thank you very much.