Grasshopper

algorithmic modeling for Rhino

custom VB tree with AppendElement dealing with tree-access inputs question

Trying to make a cutom VB tree with tree access inputs, i´m wondering which is the way to achieve the AppendElement functionallity shown in some other VB scripts here in the forum like this one:

(but instead of dealing with lists, trees are needed)

Private Sub RunScript(ByVal indexestoappend As List(Of Integer), ByVal items As List(Of Object), ByRef ctree As Object)

  Dim tree As New DataTree(Of Object)
    Dim path As New GH_Path

    For i As Int32 = 0 To indexestoappend.Count - 1
      'make path
      path = path.AppendElement(indexestoappend(i))

      'adding an element to a certain branch in the tree
      tree.Add(items(i), path)

      'deleting path information
      path = path.CullElement()


    Next
    ctree = tree

Thanks in advance

Views: 742

Replies to This Discussion

Ok , got it. If anyone´s interested (it´s very handy for multiple boolean union/difference/int solutions):

Private Sub RunScript(ByVal indexestoappend As DataTree(Of Integer), ByVal items As DataTree(Of System.Object), ByRef ctree As Object)

Dim tree As New DataTree(Of Object)

For i As Int32 = 0 To indexestoappend.BranchCount - 1
For j As Int32 = 0 To indexestoappend.Branch(i).Count - 1
Dim path As New GH_Path(i)

'make path
path = path.AppendElement(indexestoappend.Branch(i).ToArray(j))
'look at the print output to understand how the path should look
Print(path.ToString(True))


'adding element to a certain branch in the tree
tree.Add(items.Branch(i).ToArray(j), path)

'deleting path information
path = path.CullElement()


Next
Next

ctree = tree


Nice one. Thanks for sharing

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service