Forgot password?

Create an account!

Forum

« back

RhinoScript – function

Messages

Please log in to write a message.

  • 3. moodo (Oct 07, 2009 22.41):

    thank you very much.

    gr.
    md

  • 2. Johannes (Oct 07, 2009 22.13):

    hi,

    first thing i would do is to take out everything out that i don't need or use (clean up the script).
    you don't need rhino.pointcoordinates because rhino.curvestartpoint still gives you the pointcoordinates and not the identifier of a point. so you don't have to convert the point into coordinates.
    if you want to work with funtions try to use the result/output of it.

    Option Explicit

    Call Main()
    Sub Main()
           
            Dim strObject, arrLength
           
            strObject       = Rhino.GetObject("give first curve",4)
           
            arrLength       = distance(strObject)
       
            Rhino.Print "distance between start-end: " & arrLength  
           
    End Sub


    Function distance(strCrv)
           
            Dim arrStart,arrEnd
           
            arrStart        = Rhino.CurveStartPoint(strCrv)
            arrEnd          = Rhino.curveEndpoint(strCrv)
           
            distance        = Rhino.distance(arrstart,arrend)
           
    End Function

    johannes

  • 1. moodo (Oct 07, 2009 21.51):

    hey

    I wrote a function to find the length of a curve. But I get a mismatch of types.

    what iam doing wrong?
    (I know there are several methods to find distance/length, but I want to learn working with functions)

    gr. moodo

    Option Explicit
    'Script written by <insert name>
    'Script copyrighted by <insert company name>
    'Script version maandag 5 oktober 2009 18:53:22

    Call Main()
    Sub Main()
            Dim arrcurve1,arrcurve2,arrcurve3,arrcurve4
            Dim arrcurve5,arrcurves(),arrline1,arrlength
            Dim arrline2,arrline3,arrline4,arrline5,length
            Dim strobject
            strobject=rhino.GetObject("give first curve",4)
            arrlength = length(strobject)

           
           
           
    End Sub


    Function length(obj)
            Dim arrstart,arrend,arrcurve
            arrstart=Rhino.CurveStartPoint(obj)
            arrend=rhino.curveEndpoint(obj)
            arrc1=rhino.PointCoordinates(arrstart)
            arrc2=rhino.pointcoordinates(arrend)
            Dim dbllength
            dbllength = Rhino.distance(arrc1,arrc2)
            Rhino.Print "Curve length: " & CStr(dbllength)
    End Function
Recommend

Why are these buttons gray?