Grasshopper

algorithmic modeling for Rhino

hi,
I am working on a script that involves taking a grid of points and store them in a 2d array. The 2d array in the new rhino common seems to work quiet different and my array does not seem to catch all the pt as it used to do in the older sdk. The following is the code i been working on someone see if the 2d array is not written properly. Thanks a bunch




Private Sub RunScript(ByVal state As List(Of Integer), ByVal pts As List(Of Point3d), ByVal xNum As Integer, ByVal yNum As Integer, ByVal zNum As Integer, ByVal gen As Integer, ByRef outPts As Object, ByRef B As Object) 

    Dim grid(xNum,yNum) As point3d




    generateGrid(pts, xNum, yNum, zNum, grid)

    Dim nPt As New List(Of Point3d)

    For i As Integer = 0 To xNum - 1
      For j As Integer = 0 To yNum - 1
        nPt.Add(grid(i, j))


      Next
    Next


    outPts = nPt







  End Sub 

  '<Custom additional code> 

  Sub generateGrid(ByVal pts As List(Of point3d), ByVal xNum As Integer, ByVal yNum As Integer, ByVal zNum As Integer, ByRef grid As point3d(,))

    Dim x, y, z As Integer


    For i As Integer = 0 To pts.Count - 1 Step xNum


      x = 0
      y = 0
      z = 0

      For j As Integer = i To i + yNum - 1


        Dim pt As Point3d

        pt = pts(j)

        grid(x, y) = pt


        y += 1

      Next

      x += 1

    Next



  End Sub







  '</Custom additional code> 

End Class

Views: 523

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service