Feature request: Trim tree option on component outputs

We have a ton of GH scripts to turn Rhino geometry into CNC data, and I use data trees a lot to keep my data flow organized.

I find myself throwing a Trim Tree component on right after many other components’ outputs, when I don’t want the extra branch level that some components add. This can make a canvas more cluttered than it needs to be.

I’d love to see an option on the right-click menu, on the outputs of whatever components add branch levels, to “Trim Tree 1 Level” – this would be the equivalent of attaching Trim Tree to the output with its default Depth of 1. (Just like there are currently options on components outputs to graft, simplify, reverse, flatten, etc.)

Please let me know if there is a better place to post this.
Thank you!

1 Like

I know this is an older post, but I have the same issue: constantly having to trim the tree output of components to maintain my tree structure.

It seems like there is something I’m missing here. Why should this always be necessary? And/or why is it that so many components add new levels to trees? Can anyone point me to more info about this?

I think it’s whenever a given single input item could produce multiple output items, then the component adds a branch level to keep things organized. Like the Shatter component … if I input two curves, there is the possibility that each of them could be shattered into multiple segments, so it will add two branches to hold the resulting segments for each of the two input curves.

Hey, McNeel, is there a better place to put Grasshopper feature requests? Did I do this properly?

I use this method to get tree branches:

Usually tree levels are added when multiple outputs are generated from a single input. Or, the opposite when a list of inputs represent one output. Although managing that complexity can be a bit tricky depending on the situation.

I guess we should look into the specific situation to see if there are any data tree experts here that can help.

You might be doing something wrong. I work with data trees extensively and rarely need to use Clean Tree. I often require Shift Paths though.

Oh. Maybe I misinterpreted “trim the tree output”?

also to say is that -generically- data matching ignores the path of the data trees and just matches the branches 1:1, like this:

paths.gh (18.4 KB)

as you can see, the result is correct regardless of the “address” (path) of each branch: first item of A with first item of B, second with second and so on

the only real difference is in the data structure that gets inherited by the output data tree, and you can chose wether to inherit A or B by activating the “Principal” option on its input

this might look like a very silly thing, but once I got it I started using Trim Tree less and less, in exchange for grafting, which just makes things faster and life easier

Thanks for the reply, @scottd. And I understand why some components add an extra branch level. Going back to my initial post, I was just hoping to get a feature added to the outputs of any component that adds a branch level, where it would trim the branch level back up (effectively not adding the extra branch level).

Referring to my screen shot … The reason for my feature request is that I often put each piece of primary geometry on its own path (A) before passing it to the rest of the script. I find it easier to keep track of dataflows in large scripts this way. So, I don’t need the extra branch level added by, say, the Divide component. I was hoping to get a “Trim Tree 1 Level” option added to the output’s contextual menu (B), for every component that adds a branch level, which would be equivalent to putting a Trim Tree component on the output with a depth of 1 (C). That way the branch addresses of the output (D) match the input (A), and I don’t have to add Trim Tree components all over the canvas.
(Maybe it would make more sense to call the option “add branch level to output” and have its default state be on.)
Does this all make sense?

@inno I understand what you’re saying. I just like to keep my branch path numbers consistent throughout my scripts. I have some pretty big scripts, and it makes it easier to trace data progress throughout the script.

1 Like