Hello everybody,
I’ve been struggling quite hard with this tree structure. (having a flu does not help).
I have a plot with 6 groups of each 4 curves, with tree structure {Group; Curve} i.e. {5;3} to which I assign geometry by type (A,B,C,D etc.). The distibution is semirandomized output from a python script. My goal is to organize the types and their corresponding planes by ways of {Group; Curve; Type}
I’ve come to a solution, but its not very parametric as it relies on explode tree and pathmapper.
If I were to change the number of types this would break the script and require manual fixing, that is not an option for this script was, which has the goal of running through many iterations for optimization purposes.
More about the script and the different methods I’ve tried so far:
I have a plot with 6 groups of each 4 curves, with tree structure {Group; Curve} i.e. {5;3} to which I assign geometry by type (A,B,C,D etc.).
Now I’m dividing these curves by a semirandom distribution of Types A,B,C & D which I get from a Python script. These types represent geometric bocks, each with their own grid width. I’m using K/V search to get the corresponding sequence of gridsizes and then partitioning the list of types and grids to produce a list of planes per curve.
These are still grouped in the {Group; Curve} i.e. {5;3} tree format, with different list lengths depending on the number of planes.
So far so good, only the next step is sorting the planes by type so I can use orient to place the proper geometry on the proper plane. I do this by means of the member index component.
However leaves me with a tree with 4 branches each branch representing a type (A,B,C,D)
My wish however is to attain a tree structure that is organized as such {group;crv;type} i.e. {5;3;2}.
Each branch would contain just one Type i.e. B, on a specific curve within a specific group.
I’ve tried a multitude of ways to attain this tree structure, trying to work within one member index component, grafting, flattening, I’ve tree exploding the tree, quadrupling the tree and splitting the member index per type. I’ve tried splitting up the original indexes by curve and using that to create domains, which I then cross referenced with the indices of the assorted types. That finally did the trick.
However as said, it’s not a dynamic, parametric solution yet. Help and insights will be greatly appreciated! Please have a look at the script and let me know your thoughts.
forumquestion_tree sorting.gh (367.6 KB)




















