Forgot password?

Create an account!

Forum

« back

RhinoScript – Nested Array

Messages

Please log in to write a message.

  • 2. Johannes (Jun 17, 2011 20.44):

    take a look on the return of each rhinoscript function (help - plugins - rhinoscript).

    For example:
    Rhino.GetReal("...", 4) returns a single Number. So you cannot use a function like UBound().

    Dim intTrail : intTrail = Rhino.GetReal("How Many Trails This Month?", 4)

    For i = 0 To intTrail
     Call msgbox(i)
    Next

    A nested loop looks like this:

    Dim intTrail : intTrail = Rhino.GetReal("How Many Trails This Month?", 4)
    Dim arrPoints: arrPoints = Rhino.GetPoints(False,,"Pick points")
           
    Dim Point : point = array(0,0,0)

    Dim i, j
           
    For j = 0 To Ubound(arrPoints)
      For i = 0 To intTrail
                           
        Point(0) = 10 * i
        Call Rhino.AddLine(Point, arrPoints(j))
                           
      Next
    Next

  • 1. KSchillaci (Jun 17, 2011 20.07):

    I am trying to Run a nested array that asks the user for a number of trails, then from that number ask the user to select points to store for each consecutive number that was first entered.

    Basically the logic would go. "How many trails? =4
    "Select points for first trail" then store those points
    "Select Points for second trail", then store those points,
    Then run this loop until the number of trails has been reached.

    I am not sure if it is better to do a select Case operation or just a for next loop, or call a separate function entirely.

    And help would be appreciated.

    Call Main()
    Sub Main()
            'Insert Data Plot constraints as Polygon/Curve
            Dim Surface
            Dim PlotConstraints : PlotConstraints=Rhino.GetObjects("select polygon for Plot Constraints ",4)
            If isNull (PlotConstraints) Then Exit Sub
            Surface=Rhino.ObjectsByType(8)
            'Convert Plot to Planar Surface
            Dim PlotSurface,arrCenter
            PlotSurface = Rhino.AddPlanarSrf(PlotConstraints)
            arrCenter = Rhino.SurfaceAreaCentroid(PlotSurface(0))
            If IsArray(arrCenter) Then
                    Rhino.AddPoint arrCenter(0)
            End If
           
            Dim arrTrails(),i
            arrTrails = Rhino.GetReal("How Many Trails This Month?", 4)

           
            For i = 0 To UBound(arrTrails)
                    Dim Points : Points = Rhino.GetPoints(True, True, "Select Points")
            Next
           
           
    End Sub
Recommend

Why are these buttons gray?