Grasshopper

algorithmic modeling for Rhino

Is there a way to append to a data tree? Or, in other words, combine two data trees (with matching path structures) but not merge them?

For example, I have two trees:

(Paths = 2)
{0;1}
{0;2}

and

(Paths = 3)
{0;1}
{0;2}
{0;3}

and I would like to get

(Paths = 5)
{0;1}
{0;2}
{0;3}
{0;4}
{0;5}

Any ideas?

Views: 2912

Replies to This Discussion

Sameer,

Whether two trees are merged or appended all depends on path names. To do what you want you would still use the merge component (or feed both trees to the same input), but you would need to keep track of the path names yourself.

You can use the Replace Branches component to rename.

For instance:

(Paths = 2)
{0;1}
{0;2}

and

(Paths = 3)
{0;1} rename {0;3}
{0;2} rename {0;4}
{0;3} rename {0;5}

Does this make enough sense to get you started?

-taz
Taz,

Yes, that makes sense and I was able to do this. I was hoping that there would be a simpler way but yes, the above works.

Thank you for the help!
"Flatten" both paths ----> "Merge streams" ---> "Graft Tree". I think, it should work ;)
It may work if there is only one item in each path. As soon as there are multiple and different number of items in every path, the above method will not apply. Taz's method is the way to go.

Thanks in any case!
I've never been crazy about the Replace Branches component

Carlo,
Very interesting and useful. This is the first use of the "Explode Tree" component and the "Flatten Path" variable that I have seen!

However, I have upto 125 paths that I am splitting and then re-combining for various purposes. With the "Replace Branches", I can create and replace several paths using series/ranges... That may be more efficient.

It may be a tool worth putting on the wishlist for David... I can see that there may be other situations when such a tool may become useful.
Sameer,
can you post an image of the Masks and Replacement Paths you are using?
I'm curious to see what your solution is.
Sure... here you go:

I am trying to do something almost exactly like this, but I cannot seem to get "Replace Branches" to work. What am I doing wrong?

Never mind. Now I see why everyone was trying to remove the curly brackets.
for others who end up here looking for solutions:

http://www.grasshopper3d.com/forum/topics/depositing-lists-into-bra...
This is something that has been bugging me so I'll post it here (where no one will find it...)

Can anyone show me the proper use of the SubString expression to remove curly brackets? I'm using 2 separate functions instead instead of one...

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service