Grasshopper

algorithmic modeling for Rhino

How to toggle whether a branch is appended after another branch?

Hi, I want to toggle whether the in_2 will be merged with in_1 by the toggle state. Does anyone know how to merge to input tree with its own structure remained?

The "a = in_1 + in_2"does not work.

Any script language is OK, not limited to python.

Views: 758

Replies to This Discussion

in_1.MergeTree(in_2)

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks for your reply.

It's my first time to use "Tree Access". So... how can I get the output? in_1 is Null, a = in_1.MergeTree(in_2) is Null...

I don't get it. If you have two non-null DataTree instances and you want to merge them, use the MergeTree() method. If you only have one DataTree there is nothing to merge.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Well, the two trees each has 2 branches. I want the final tree have 4 branches. The MergeTree() will make the final one 2 branches with each double the children's number.

Though I use other method to accomplish the goal, I still want to here you advice.

Ok, so you want to combine all lists in all trees and change the paths so they don't collide. In that case you're better off just making a new DataTree and appending the lists inside loops:

Dim tree As New DataTree(Of Object)
Dim idx As Int32 = -1

For i As Int32 = 0 To x.BranchCount - 1
  idx += 1
  tree.AddRange(x.Branches(i), New GH_Path(idx))
Next

For i As Int32 = 0 To y.BranchCount - 1
  idx += 1
  tree.AddRange(y.Branches(i), New GH_Path(idx))
Next

For i As Int32 = 0 To z.BranchCount - 1
  idx += 1
  tree.AddRange(z.Branches(i), New GH_Path(idx))
Next

Where x, y and z are DataTree<Object>

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Though I try to avoid using DataTree, this seems to be the easiest method.

Thanks for your time.

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