Forgot password?

Create an account!

Forum

« back

RhinoScript – problems with array

Messages

Please log in to write a message.

  • 2. sebaster (Feb 02, 2016 19.57):

    i find the mistake line 24 without arr(), now it works

  • 1. sebaster (Dec 04, 2015 15.53):

    Hi,
    i have a problem with the following script. It works for using only one closed curve but not for doing that with more curves at the same time. There is something wrong with the Array "arr". Can someone please help?

    <rvb>
    Option Explicit


    Call Main()
    Sub Main()


    Dim strObjects : strObjects = Rhino.GetObjects("select curves ", 4)

    Dim strObject

    For Each strObject In strObjects

    Dim arrCurve : arrCurve = Rhino.ExplodeCurves(strObject, False)

    Dim i, arr(), temp
    Dim IntCount : IntCount = 0


    For i = 0 To UBound(arrCurve)

    temp = Rhino.CurveLength(arrCurve(i))

    ReDim Preserve arr(i)
    arr(i) = temp
    Rhino.ObjectName arrCurve(i), CStr(temp)

    IntCount = IntCount + 1
    Next

    'sort
    Dim arr2 : arr2 = Rhino.SortNumbers(arr, vbTrue)
    Dim strLang : strLang = arr2(IntCount - 1)

    Rhino.PrintEx strLang
    Dim Name : Name = "" & strLang & ""


    Dim arrObj : arrObj = Rhino.ObjectsByName(Name)

    Dim strCurve : strCurve = arrObj(0)

    Dim arrMidPoint : arrMidPoint = Rhino.CurveMidPoint(strCurve)


    Rhino.AddPoint arrMidPoint

    Rhino.DeleteObjects arrCurve


    Next


    End Sub
    </rvb>

Recommend

Why are these buttons gray?