Forgot password?

Create an account!

Forum

« back

RhinoScript – Offset Curve

Messages

Please log in to write a message.

  • 2. Hanno (Dec 10, 2012 20.30):

    Hi,

    I would say the problem is the following: OffsetCurve can return more than one curve (in case Rhino cannot join the offset). You do not check for this but blindly use the "LastObject". At some point this happens to be the small line in your picture, which is used for all the offsets from then on.

    BTW: You are operating with very small distances. Make sure your model tolerance is accordingly set!


    Hope that helps

    Hanno

  • 1. full-blood (Dec 09, 2012 19.19):

    Hello,

    I've written a script to offset a curve, with an "exponential" distance.
    It's working, except a strange problem, as you an see in the attached image.

    Have you an idea why?!

    Option Explicit
    'Script written by <insert name>
    'Script copyrighted by <insert company name>
    'Script version Sunday, 09 December 2012 17:01:26

    Call Main()
    Sub Main()
            Const rhCurve = 4

            Dim strObject
            Dim i, x
            Dim decalage
            Dim palier
            Dim offsetnb
            Dim lastobj
            Dim dist
            Dim maxdist
           
            offsetnb = 150
            dist = -0.01
            decalage = 0.002
            palier = 1
            maxdist = -0.05
           
            strObject = Rhino.GetObject("Select a curve", rhCurve)

            If Rhino.IsCurve(strObject) Then
                   
                            Rhino.Print "Distance : " & dist
                           
                            offset dist, strObject
                           
            End If
           
            Rhino.Command("_SelLast")
            Dim blaObject
            Dim fstobj
            'blaObject = Rhino.LastObject
            fstobj = Rhino.FirstObject

            'Rhino.Print "Object identifier: " & blaObject
            'Rhino.SelectObject blaObject
            'Rhino.OffsetCurve blaObject, Array(0, 0, 0), dist
            For x = 0 To offsetnb
           
                    For i = 0 To palier - 1
                            Rhino.Print "Distance offset : " & dist
                    offset dist, fstobj
                    fstobj = Rhino.FirstObject
                   
                    Next
                   
                    If dist >= maxdist Then
                            dist = dist - decalage
                    End If
                   
            Next   
           

           
    End Sub

    Function offset (dist, offObject)
            Rhino.OffsetCurve offObject, Array(0, 0, 0), dist, , 3
    End Function
Recommend

Why are these buttons gray?