Dynamic draw crash with interpolatedcurveonsurface [crash solved]

In trying to get a feel for the working of dynamic draw, I have am mimicing interpolated curve on surface. sometimes rhino will crash after picking the first point already, sometimes just after a couple of picked points, and sometimes it doesn’t crash. Any idea what is going wrong?

However when I just use the (commented out) control point curve instead, things run fine.

see script below:

    import Rhino
    import rhinoscriptsyntax as rs
    from System.Drawing import Color
    import scriptcontext as sc

    def DynamicCrvOnSrf():

        def drawmycurve(sender,e):
            points[len(points)-1]=e.CurrentPoint#change last point to CurrentPoint
            curve=rhsrf.InterpolatedCurveOnSurface(points,0.1)
            #curve=Rhino.Geometry.Curve.CreateControlPointCurve(points,3)
            e.Display.DrawCurve(curve, Color.Black,1)
            #e.Display.DrawDottedPolyline(points,Color.DarkBlue,False)
            e.Display.DrawPoints(points,0,3,Color.Black)

        def getpoint():
            gp.Get()
            if gp.CommandResult() == Rhino.Commands.Result.Success:
                pt=gp.Point()
                if len(points)==0:#initial point
                    points.append(pt)
                    #add one temporary point that gets overriden in drawmycurve()
                    points.append(tempPoint)
                elif len(points)>=2:
                    points.append(tempPoint)#add new temporary point
                gp.DynamicDraw+=drawmycurve
                #recursion: getpoint calling itself after a point has been picked:
                getpoint()

            elif len(points)>2:#2 picked points +1 temporary point
                #remove last added preview point
                del points[-1]
                rs.AddInterpCrvOnSrf(srf, points)

        srf=rs.GetObject("select surface to draw on", rs.filter.surface)
        if srf==None:
            return
        rhsrf=rs.coercesurface(srf)
        tempPoint=Rhino.Geometry.Point3d(0,0,0)
        gp=Rhino.Input.Custom.GetPoint()
        gp.SetCommandPrompt("Draw on surface")
        gp.Constrain(rhsrf, False)
        points=[]
        getpoint()

    if( __name__ == "__main__" ):
        DynamicCrvOnSrf()
1 Like

seems it only crashes on the mac, or at least easier

crash now solved, updated script here