Forgot password?

Create an account!

Forum

« back

RhinoScript – writing values to 2d array

Messages

Please log in to write a message.

  • 2. clausneergaard (Jul 16, 2010 23.57):

    oh, just figured it out.


    Option Explicit

    Call Main()
    Sub Main()

            Dim arr2D
            Dim count, i
           
            count = 0
            ReDim arr2D(count)
           
            For i = 0 To 10 Step 1
                    ReDim Preserve arr2D(count)
                    arr2D(i) = Array(rnd*100,rnd*200,rnd*300)
                    Rhino.Print("arr2D(" & i & "): " & arr2D(i)(0) & ", " & arr2D(i)(1) & ", " & arr2D(i)(2))
                    count = count+1
            Next
           
    End Sub
  • 1. clausneergaard (Jul 16, 2010 19.39):

    again, I am a bit confused about this one. how do I write values to a 2D array (or is it called a nested array? hmmm ..) I'm thinking the problem is that I'm not defining the size of the second level of the array?

    I get a 'type mismatch' when trying to run the script below.

    any input would be appreciated!
    Thanks,
    Claus

    Option Explicit

    Call Main()
    Sub Main()

            Dim arr2D
            Dim count, i
           
            count = 0
            ReDim arr2D(count)
           
            For i = 0 To 10 Step 1
                    ReDim Preserve arr2D(count)
                    arr2D(i)(0) = 100
                    arr2D(i)(1) = 200
                    arr2D(i)(2) = 300
                    count = count+1
            Next
           
    End Sub
Recommend

Why are these buttons gray?