Forgot password?

Create an account!

Forum

« back

RhinoScript – How can i give a name to a point in a function

Messages

Please log in to write a message.

  • 3. maxofa (Nov 12, 2009 05.31):

    Hi Hanno,

    Thanks for your precious help. It was very useful. You know when you are running circle; nothing is better that someone like you to put you back on track.!

    For the others here is the revised script… it might help you at one point

    Call Main()
    Sub Main()

    Dim crv, ptNew
    crv = Rhino.GetCurveObject ("select curve")

    Dim nCrv
    nCrv = newCurveLength (crv)
    'nCrv = Rhino.PointCoordinates (nCrv)

    Dim arrPt1
    arrPt1 = Rhino.AddPoint(array(45,45,0))
    arrPt1 = Rhino.PointCoordinates (arrPt1)

    Call Rhino.AddLine (arrPt1,nCrv)

    End Sub

    Function newCurveLength (crv)

    Dim lold, lnew
    lold = Rhino.CurveLength(crv(0))
    lnew = 5

    Dim dom
    dom = Rhino.CurveDomain(crv(0))

    Dim pts,t
    pts = Rhino.DivideCurveLength(crv(0), lnew)
    t = Rhino.CurveClosestPoint(crv(0), pts(1))

    Dim ptNew
    ptNew = Rhino.AddPoint(pts(1))
    ptNew = Rhino.PointCoordinates (ptNew)

    Dim endCurve
    endCurve = Rhino.TrimCurve (crv(0), Array(dom(0), t))

    newCurveLength = ptNew

    End Function

  • 2. Hanno (Nov 10, 2009 10.26):

    Hi,

    you need your function to return the new point id. Currently your function always returns NULL (newCurveLength = Null). Just add newCurveLength = ptNew at the end.

  • 1. maxofa (Nov 07, 2009 17.24):

    Hi all,
    This is the first time I am posting something here so thank you in advance….
    I wrote this function that set a new curve length. My problem is that when I Call newCurveLength (crv1) in a FOR perhaps I have to way to retrieve this point because it does not have a name. So how can I give a name to each of these new point so that I can connect them later on in my FOR with other points


    Here a piece of the code

    Call Main()
    Sub Main()

    Dim crv1 : crv1 = Rhino.GetObject ("pick curve", 4)
    Call newCurveLength (crv1)

    End Sub


    Function newCurveLength (crv)
    newCurveLength = Null

    Dim lineold, linenew
    lineold = Rhino.CurveLength(crv)
    linenew = Rhino.GetReal("New curve length",1 )

    Dim dom
    dom = Rhino.CurveDomain(crv)

    Dim pts,t
    pts = Rhino.DivideCurveLength(crv, linenew)
    t = Rhino.CurveClosestPoint(crv, pts(1))

    Dim ptNew
    ptNew = Rhino.AddPoint(pts(1))

    Dim endCurve
    endCurve = Rhino.TrimCurve (crv, Array(dom(0), t))
    End Function

Recommend

Why are these buttons gray?