Grasshopper

algorithmic modeling for Rhino

I am trying to script a data tree of integers. 
Within a loop, I would like to use an item I assigned to a previous branch in a new one. I can't figure out how to retrieve the item from the tree. Can you help?
below is the vb script. the bold section is where I am trying to retrieve the integer I assigned to Path(0) index (1) to use in path(1) index (0). 
Thanks for your help!

__________________________________________________________________________________
Private Sub RunScript(ByVal gen As Integer, ByRef A As Object) 
    'your code goes here…

    Dim tree As New DataTree(Of Integer)
    Dim i As Integer
    Dim j As Integer

    For i = 0 To gen
      If i = 0 Then
        Dim path As New GH_Path(i, j)
        Dim myrow As New List(Of Integer)
        myrow.Add(0):myrow.Add((2 ^ (gen - 1)) / 2)
       
 For j = 0 To myrow.Count() - 1
          tree.add(myrow(j), path)
        Next

      Else If i = 1 Then

        Dim path As New GH_Path(i, j)
        Dim myrow As New List(Of Integer)
        Dim g As Int32 = tree.item(path(0), 1)       
        myrow.Add(g / 2)

        For j = 0 To myrow.Count() - 1
          tree.add(myrow(j), path)
        Next
      Else
        'Dim path As New GH_Path(i, j)

        'tree.add(myrow, path)
      End If
    Next

    A = tree

Views: 486

Replies to This Discussion

Did you figure out how to resolve this issue?
I didn't figure out the code to access an item in the scripted data tree. Though now I have a guess what the problem might have been.
I found a simpler way to do what I wanted, without needing that code.
And Thanks for asking. I appreciate it.

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