Data tree branch weaving

Hello,

I’ve trouble finding a solution to the following problem:

I’ve got three data trees(not intended hehe) which consits of n branches. These data trees all have the same amount of branches. I want to weave these branches in n seperate data trees like the picture shown below:

I’ve tried putting the leaves of the branches into groups and weaving them together. This solves part of the problem but i cannot figure out how to iteratively seperate the branches into n trees again. Als the trees in this example only has 3 branches, but i would like for the script to work with any amount of branches.

Could some help me with this?

This is de grasshopper file:

Data branch weaving.gh (15.5 KB)

I don’t fully understand your goal? “seperate the branches into n trees” :question:

Have you considered unflattening the Group outputs and merging them?


Data branch weaving_2024Oct23a.gh (18.3 KB)

By the way, Group wants geometry, not numbers. When you Ungroup the merge output you get only nulls. :thinking:


Data branch weaving_2024Oct23b.gh (24.0 KB)

But if you actually want separate trees you must “explode” the tree after merge:


Data branch weaving_2024Oct23c.gh (23.0 KB)

If you are really concerned about N trees, you probably don’t want to explode the tree.

1 Like

I just noticed that your three data trees each have duplicate branches :interrobang: All branches for each tree are the same :interrobang: Are these point coordinates, by any chance?

Regardless, there are many ways to organize data trees, which is partly why they get confusing.

You might want to look at Num2Pt and Pt2Num.
This is only your first data tree but offers several ways to organize all three:


Data branch weaving_2024Oct23d.gh (11.8 KB)

Aah thank for your swift and numerous replies!

Yes i’m quite aware that the data is just numbers instead of points. I just needed some quick placeholder data. The real data is indeed points. The group component functions just as well with only numbers apparently hehe. Nice trick in converting numbers to points and visa versa!

But unfortunately its not quite what I was looking for. I want to create a x amount of separate data trees depending on the amount of branches of the 3 starting data trees.

So when i start with 3 data trees with 4 branches each, i want to weave those branches together and create 4 separate new data trees.

I updated the script to clarify:

Data branch weaving_update.gh (52.0 KB)

For just a few data trees its alright to use the explode tree, but the the amount of branches will be varying and can reach quite large numbers. That’s why i cannot use the explode tree component.

Do you have any idea how to do this with native grasshopper components? Or do i have to use scripting for this?

I have many ideas but don’t see the big picture yet. Am away from my computer for awhile.

As I said, that’s not the case.

I’ve noticed that people who don’t code become project managers.
:rofl:

if this is OK to Explode Tree with 5 branches…

…it might not be OK to bang it when branches are 250 :upside_down_face:

main point: what are you going to do with those branches that you want to isolate one by one?"

because, for instance, let’s say that you want to move each branch by a different Vector, then the best solution is to create a matching data tree with those vectors, and just apply those simultaneously to your data tree of points

if you really need something like “I want to move points of only branch {3}” then you can move everything else by a {0,0,0} vector (which is not very good practice -of course- if you have thousands of points to be moved by zero, it’s still processing time)… so in that case you might want to Split Tree and merge back afterwards, like:

this way you sort of “extract” branch {3}, do something just to that, then put it back together with the other branches

so the main question, what are the next steps you wanted to do with those data? :smiley:

3 Likes

I’ve looked at your code and have no idea what you are doing. Good luck and have fun.

1 Like

If this is what you want to achieve, maybe pathmapper is what you’re looking for.
You still have to connect any new tree to the entwine component, and you can leave open inputs empty (to reduce clicks).


Data branch weaving.gh (21.0 KB)

2 Likes

Helloo Inno,

It is not so much about the data or the application of the script. I just want to figure out how to do this kind of data tree manipulation. I want to build an adaptive script that could weave the branches of 3 main data trees together with any amount of branches into new data trees with 3 branches each. The amount of new data trees created depends on the number of branches of the original data trees. So this can be 5 branches, which could be done with explode tree or the data mapper, or 500 branches, which become really tedious is working with entwine or explode tree.

Although it is clear in text, i think the example file is not the greatest explanation of what i want to achieve because a lot of people are misunderstanding it haha.

I have the feeling this could be very difficult with native components only, i think i ll to take a programming course in python hehe

Helloo Antoine,

Oh yess that will work for a set and low amount of branches, but if I want to sort 3 trees with 500 branches each into 500 new trees with three branches each, than it would become very messy.

Python or not, how do you expect to get “new trees” without separate outputs for each new tree? Not sure if this is a terminology problem or a conceptual problem but I’m more sure now that I made the correct decision to give up on it.

If there’s no way to create all the points organized (branched) into a single tree at once, then you gotta have to connect them somehow.

One could play with python or metahopper to make automated wire connections, but definitely sounds like overly complicating things.

I might be missing something here, but isn’t this what you want?

Hey there!

For this kind of problem, I tend to prefer a coded approach.
DataBranchWeaving_CSharpSolution.gh (8.8 KB)

Not sure if I understood exactly what you want to do, but here is something to get you started if you want to try a C# approach. What this does is to take the first branche of each tree and put them in the first branch of the result, then it does the same for the following branches.

The algorithm proposed only works if you have as many tree as the number of branch per tree, but if you’re familiar with basic coding, you should be able to tweek it to suit your need.

Hope this helps!