algorithmic modeling for Rhino
For some data visualisation/ infographics I did a good while ago, there was the necessity to know the branch count of direct descendants at the different depths of the tree. So I don't mean just the final branches.
Starting at the trunk, I would need an integer of the number of direct descendants, so oh at the core: it has 3 branches, then the first branch of that, ah it has 5, the second branch to the trunk has 2, etc. yada yada.
Back then there was a script written for the specific one i needed and some funky string actions to help process. But I was always wondering, there must be a clean solution, has anyone come across such a thing?
I realize there is no component, but maybe someone wrote a script, uncovered a functionality?
Tags:
Exactly that David!
This might be useful for someone.
To traverse the path in nested loops I do it like so:
Get the max number of branches at each depth by
int depthLayerOne = tree.Paths[tree.PathCount - 1].Indices[0] + 1;
int depthLayerTwo = tree.Paths[tree.PathCount - 1].Indices[1] + 1;
It gets the last element from the list of paths, which would have the max number of branches at each depth level as indices. I add one to those, to make it easy to loop.
I can do the 0 and 1 index into the 'Indices ' array because in my case I know the number of layers in my tree.
If you don't know that in advance you can use a list to loop through.
Nested looping like so:
for(int i=0; i<depthLayerOne; i++)
{
for(int j=0; j<depthLayerTwo; j++)
{
// code
}
}
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by