Can anyone tel me, how to split a list based on the nr. of item in each branch?
I would like to separate this list in 2 lists based on the nr. of items in each branch so one list contains only the branches with 3 items and one list with the branches with 2 items...
Feed the data into a "list length" component, test for equality (list length = 2) and then use "dispatch" to separate the data into two sets of branches. If having the resulting data contain branches with 0 items bothers you, you can use "clean tree" to remove those empty branches.
...well, we have the "item_count" in the Path Mapper but I'm not sure how to use it properly! I remember David mentioning a syntax for the Path Mapper, but I can't find that post...
use path mapper to map from whatever it is to start i.e. {0;0;A} to {(If(item_count=2,0,1))}
Because an equality expression evaluates to true or false which convert automatically to zero or one, you can even simplify it to map to {item_count=2} and leave it at that. But by nesting the if solution as above, it would be possible to separate lists of 3 or more different lengths.
Wouldn't it be more flexible to use the list length and dispatch? Path mapper always seem so rigid to me. Most changes in the up stream definition will invalidate your expressions.
Still, I'd like to see some documentation on available path mapper and expression syntax. Did you find that post by David?
but believe it or not, the documentation is right in grasshopper; just double click the path mapper icon in the toolbar and a help doc comes up with a detailed explanation including the special placeholders item_count, path_count, and path_index. (in a little tiny note at the bottom)
quote:
There are additional placeholders available for target masks which allow you to track your overall progress in the data tree iteration.
The "path_index" placeholder is an integer which is incremented for every new data tree branch that gets loaded. For example the "{path_index}" target mask would simplify all branches in the entire tree, while keeping all branches separate.
The "path_count" placeholder represents the total number of branches in the current tree.
The "item_count" placeholder represents the total number of items in the current branch.