Forgot password?

Create an account!


« back

RhinoScript – perpendicular in a FOR loop


Please log in to write a message.

  • 1. maxofa (Nov 20, 2009 04.23):


    First, my issue is in a FOR loop. I wanted to create a point on a curve at a right angle from another test point. This one worked and it was my test. See script below. After, I inserted in my For loop and it seems like it does not read the curve that it need to be perpendicular anymore but instead place the perpendicular point right on the test point coordinates. Anyone have an idea what is going wrong. Thank you so much1

    Test Script that work:

    Call Main()
    Sub Main()

    Dim strObject, arrPoint, dblParam, arrNormal, pt1

    strObject = Rhino.GetObject("Select a curve", 4)

    arrPoint = Rhino.GetPointOnCurve(strObject)

    dblParam = Rhino.CurveClosestPoint(strObject, arrPoint)

    arrNormal = Rhino.CurveTangent(strObject, dblParam)

    pt1 = Rhino.PointAdd (arrPoint, arrNormal)


    End Sub

    And My FOR SCRIPT that does not work properly:

    Call Main()
    Sub Main()

    Dim i, j, k
    Dim x, y, z
    Dim imax, jmax, kmax

    imax = Rhino.GetInteger ("max number of point in x", 4)
    jmax = Rhino.GetInteger ("max number of point in y", 4)
    kmax = Rhino.GetInteger ("max number of point in z", 2)

    imax = imax - 1
    jmax = jmax - 1
    kmax = kmax - 1

    ReDim arrPtsMatrix(imax, jmax, kmax)

    Call Rhino.EnableRedraw(True)

    For i = 0 To imax
    For j = 0 To jmax
    For k = 0 To kmax

    x = i * 4000'
    y = j * 4000'
    z = k * 1000'

    arrPtsMatrix(i,j,k) = array(x,y,z)

    'Call Rhino.AddTextDot(i&j&k, arrPtsMatrix(i,j,k))

    If i>0 And j>0 And k>0 Then

    Dim lDiag100_111
    lDiag100_111 = Rhino.AddCurve(array (arrPtsMatrix(i,j-1,k-1),arrPtsMatrix(i,j,k)))
    Call Rhino.ObjectColor(lDiag100_111, vbRed)

    Dim lDiag110_011
    lDiag110_011 = Rhino.AddCurve(array (arrPtsMatrix(i,j,k-1),arrPtsMatrix(i-1,j,k)))
    Call Rhino.ObjectColor(lDiag110_011, vbBlue)

    Dim lDiag010_101
    lDiag010_101 = Rhino.AddCurve(array (arrPtsMatrix(i-1,j,k-1),arrPtsMatrix(i,j-1,k)))
    Call Rhino.ObjectColor(lDiag010_101, vbGreen)

    Dim dblParam, arrNormal
    dblParam = Rhino.CurveClosestPoint(lDiag010_101, arrPtsMatrix(i,j-1,k-1))
    arrNormal = Rhino.CurveTangent(lDiag010_101, dblParam)
    Dim pt1
    pt1 = Rhino.PointAdd (arrPtsMatrix(i,j-1,k-1), arrNormal)

    End If

    Call Rhino.EnableRedraw(True)

    End Sub


Why are these buttons gray?