Forgot password?

Create an account!

Forum

« back

RhinoScript – howto create line and use end points

Messages

Please log in to write a message.

  • 2. jamby (Oct 15, 2010 04.57):

    Hello again

    A day or so after writing this I clobbed together some code using the example from RhinoScript.org

    Option Explicit

    Call CP()
    Sub CP()
            Dim arrcen1, arrcen2, dbldist
            Dim arrStart, arrEnd
             Rhino.Command("line")

            Dim arrObjects, strObject, strObject1
            arrObjects = Rhino.LastCreatedObjects
            If IsArray(arrObjects) Then
            For Each strObject1 In arrObjects
    '       Rhino.Print "Object identifier: " & strObject1
            strObject = strObject1
            Next
            End If

            arrStart = Rhino.CurveStartPoint(strObject)
            arrEnd = Rhino.CurveEndPoint(strObject)
            dbldist = Rhino.Distance(arrStart,arrEnd)
            Call Rhino.AddPoint( funcmid(arrStart, arrEnd, dbldist) )
    End Sub

    Function funcmid(ptA, ptB, distC)
            funcmid = array((ptA(0)+ptB(0))/2,(ptA(1)+ptB(1))/2,-(distC)/2)
    End Function

    and so on I go.
    Jamby

  • 1. jamby (Oct 09, 2010 17.42):

    Hi
    Working with V3 on a 2d model plane.
    I am trying to create a line using Rhino.Command("line") because I want the snap line displayed. But I have to then select the newly created line to get the end points in an array so I can create a point between the end points with a cacluated "Z" depth. The following code shows several of the options I have tried with the line commented out.
    Does anyone know a method that will create the line and pass the end points on??
    Thanks
    jamby

    Option Explicit

    Call CP()
    Sub CP()
            Dim arrcen1, arrcen2, dbldist, strObject
            Dim arrStart, arrEnd
            Rhino.Command("line")

            strObject = Rhino.GetObject("select curve")
            'strObject = Rhino.LastCreatedObject
            'strObject = Rhino.Rhino.Command("line")

            arrStart = Rhino.CurveStartPoint(strObject)
            arrEnd = Rhino.CurveEndPoint(strObject)
            dbldist = Rhino.Distance(arrStart,arrEnd)
            Rhino.print "Dist:" & CStr(dbldist)
            Call Rhino.AddPoint( funcmid(arrStart, arrEnd, dbldist) )
    End Sub

    Function funcmid(ptA, ptB, distC)
            funcmid = array((ptA(0)+ptB(0))/2,(ptA(1)+ptB(1))/2,-(distC)/2)
    End Function
Recommend

Why are these buttons gray?