Forgot password?

Create an account!

Forum

« back

RhinoScript – Why does my script returns a null variable?

Messages

Please log in to write a message.

  • 3. Evert Amador (Feb 24, 2009 12.44):

    Hi Hanno,

    thanks a lot for replying!

    Silly me, trying to get curvature from a polyline!!!
    Using EvaluateCurve the script works and also the indexes issue is solved.

    I shall proceed with the next step of my script and will post it when finished.....someday soon I hope.

    Regards

  • 2. Hanno (Feb 24, 2009 11.18):

    Hi,

    you are using CurveCurvature on polylines which are not curved by definition. Try using EvaluateCurve to get your points instead.
    And the script goes out of range because you mixed up your array indexes: arr3DPts(v,u) should be (u,v).

    Greetings

    Hanno

  • 1. Evert Amador (Feb 23, 2009 10.50):

    Hi All,

    I been trying to make this script work and I simply don't understand whay arrp5 and arrp6 on line 91 and 92 return null?

    I also don't understant why if PtsOnRow and RowCount are different the script goes out of range.

    Any help with this will be much appreciated.

    Cheers

    Evert

    Option Explicit
    'Script written by <Evert Amador>
    'Script copyrighted by <Genius Loci>
    'Script version 26 January 2009 21:16:24

    Call Main()
    Sub Main()
    Dim strObject
    Dim arrDomU, arrDomV
    Dim PtsOnRow
    Dim RowCount
    Dim m

    strObject = Rhino.GetObject ("Select Surface", 8, True)
    If IsNull(strObject) Then Exit Sub

    PtsOnRow = Rhino.GetInteger ("Points on Row", 10, 1, 20)
    If IsNull (PtsOnRow) Then Exit Sub

    RowCount = Rhino.GetInteger ("Row Count", 10, 1, 20)
    If IsNull (RowCount) Then Exit Sub

    m = Rhino.GetInteger ("Maximum Height", 2, 1, 20)
    If IsNull (m) Then Exit Sub

    arrDomU = Rhino.SurfaceDomain(strObject, 0)
    arrDomV = Rhino.SurfaceDomain(strObject, 1)

    Dim vSpacing : vSpacing = (arrDomV(1)-arrDomV(0))/(RowCount)
    Dim uSpacing : uSpacing = (arrDomU(1)-arrDomU(0))/(PtsOnRow)

    Dim arr3DPts : ReDim arr3DPts(PtsOnRow, RowCount)


    Dim u,v, dU, dV
    Dim arrParam, arrPt

    Call Rhino.EnableRedraw(False)
    For v = 0 To RowCount
    For u = 0 To PtsOnRow

    dU = arrDomU(0)+(u * uSpacing)
    dV = arrDomV(0)+(v * vSpacing)

    arrParam = Array(dU,dV)
    arr3DPts(v,u) = Rhino.SurfaceCurvature(strObject, arrParam)



    Next
    Next


    Dim p1, p2, p3, p4
    Dim arrp5(), arrp6()
    Dim arrNormal1, arrNormal2, arrVector1, arrVector2
    Dim strCrv1, strCrv2, strCrv3, strCrv4
    Dim strPolyline
    Dim strCr
    Dim c1, c2, c3, c4
    Dim n, PolylineDomain

    For v = 0 To RowCount-1
    For u = 0 To PtsOnRow-1

    p1 = arr3DPts(v , u)(0)
    p2 = arr3DPts(v + 1, u)(0)
    p3 = arr3DPts(v + 1, u + 1)(0)
    p4 = arr3DPts(v, u + 1)(0)


    Randomize
    n = rnd * m
    arrNormal1 = Rhino.VectorScale(arr3DPts(v, u)(1),n)
    arrNormal2 = Rhino.VectorScale(arr3DPts(v + 1, u)(1),n)
    arrVector1= Rhino.VectorAdd(p1, arrNormal1)
    arrVector2= Rhino.VectorAdd(p2, arrNormal2)

    p1 = arrVector1
    p2 = arrVector2

    strPolyline = Rhino.AddPolyline (Array (p1, p2, p3, p4, p1))
    PolylineDomain = Rhino.CurveDomain (strPolyline)
    Dim i, j, k

    For i = 0 To 20

    j = rnd * PolylineDomain(1)
    k = rnd * PolylineDomain(1)

    arrp5 = Rhino.CurveCurvature (strPolyline, j)
    arrp6 = Rhino.CurveCurvature (strPolyline, k)

    Call Rhino.AddCurve (Array (arrp5(0), arrp6(0)), 1)

    Next



    Call Rhino.AddSrfPt (Array(p1, p2, p3, p4))


    Next
    Next
    Call Rhino.EnableRedraw(True)

    End Sub

Recommend

Why are these buttons gray?