Dispatch tree but maintain tree structure

I’m trying to stretch some breps by their component surface control points, but only those control points which are inside a bounding box (just like “stretch” in Autocad but 3D). I can get a list of points, organized like {brep,surface}[point], and can run that through “point in brep” using the bounding box to get a corresponding list of true/false with the same tree structure.

My problem is, I need to keep my tree structure organized so I can reconstruct the surfaces in to breps at the end. If I dispatch my points with my true/false tree (to send true points to a transform) - it flattens the structure. Ideally I would like a dispatch function which retains tree structure but inserts nulls I guess? I was also hoping stream gate might work but apparently it doesn’t allow trees or lists as a gate.

I was trying to figure it out using member index for value “True”, but I realized there is probably a simpler way to do this that I am missing. I am new to grasshopper and just figuring out data trees.

PS. I’d also appreciate any tips for how I can eventually recombine my original tree with my transformed tree according to my boolean tree (haven’t started working on that yet)
Thanks!

stretch brep by control points inside box.gh (21.6 KB)

I guess more generally: In programming when iterating through a list, you can use the iteration number in your loop. In grasshopper, when a node iterates through a tree structure, is there a workflow that exposes the branch path for each iteration? Like to do some work with identical or similar tree structures?

happy new year!
I think you could use something like this (here with a 10 units +Z transform)

stretch brep by control points inside box_Re.gh (21.8 KB)

2 Likes

Hey thats perfect. Thank you!

Happy new year!

Please have a look at Sift-Combine-pattern also. It allows you to do a sort of “if-else”, and then combine back to the original DataTree shape. If you zoom in on the Sift component, you can add multiple outputs as well. It adds nulls in the DataTree to maintain the structure.

In the screenshot, the points inside the Box are moved by one Vector and all the other points are moved by another Vector.

2 Likes

Hey thank you for this. This worked perfectly for my next task - which was doing the same with sets of points.

It’s interesting that combine works without a pattern input - I guess it just uses the item indices to arrange the output list. Seems like it’s designed to work directly with Sift - using the null place holders. Very useful.

Thank you!

1 Like