Working with datatrees

I have a fairly simple question, but I still have a hard time decoding what to do.

I am working on a script that uses curves to generate woodconstructions, this technically does not matter for my question, but whatever.

I am wondering how you create scripts that works just as well with datatrees AND single items, that are technically flattened.
The problem I’m stumbeling into is that my script works just fine if I’ve drawn let’s say 5 curves to work with, but whenever I want to use just 1 curve, my whole script changes, since now it’s not a datatree, but just a single curve.

What do you do, to circumvent this?

The problems, usually, appears when you go from one to many, not otherwise.
Share your code and we will have a look.

1 Like

Depends on the script. Often a merge node is useful because if some inputs are missing it doesn’t matter - you still get the outputs of whatever is still connected.

Config Tester.3dm (35.7 KB)
Wood Config 3.0.gh (29.9 KB)

Hi Rasmus
Congratulations for well structured file but I don’t want to install these things:


You don’t need Bubalus to offset curve or Threesloth to Shift Paths.
I don’t have any test machine nearby to install those. I have a strict policy to keep my library folder as clean as possible (the policy of many users). Sorry.
Can you simplify it somehow to illustrate the problem?

Ahh, of course, my bad!

Give this script a whirl
piotr_test.gh (7.3 KB)

This script is just to show how the data structure changes from multiple objects in a datatree to one.

It is very simplified compared to the other script, I just want to figure out a way to work with changing datatree sizes

If I switch between a single and multiple curves it works fine?

Rhino_t0MsWP1ohg

If you want the tree structures behave the same way you have to skip the tree simplification:


Since you can’t simplify the tree for single item it merges at the and the data from two different streams. To mimic that follow my example.

As you can see in the panel in your screenshot, the datastructure seems to mess up, by putting a lot of branches on some of the items, even with “simplify” turned on.

How am I supposed to keep the datastructure streamlined, for multiple AND single items?

How about using weave instead of merge?

You are asking the wrong question. The real question here is: how do you want your tree to look like at the end?
You can use entwine component:


The output will always look the same regardless the number of entries.