Drag knife toolpath generation

I’ve managed to generate the circles on places the curve is not contiuous, but it’s kind of hacky…
Hear me out: First you create a polygon, then you use the FilletCorner command with 0.05 radius,
then you divide the curve in 0,001 parts and run my script and it kinda creates that effect.

It’s hacky but whatever does the trick right?
If someone has tips/other solutions i’d greatly appreciate it!

New code can be found here: (doesn’t include the filletCorners command yet)

import rhinoscriptsyntax as rs
import Rhino
import scriptcontext
import System.Guid

class TanLines:
    def __init__ (self, INcurve, INdivideBy, INradius):
        self.curve = INcurve
        self.divideBy = float(INdivideBy)
        self.radius = int(INradius)

    def tanPoints(self):
        doms = rs.CurveDomain(self.curve)
        minDom = doms[0]
        maxDom = doms[1]
        points = Rhino.Collections.Point3dList(30)
        lengthCurve = rs.CurveLength(self.curve)
        self.numOfDivs = lengthCurve/self.divideBy

        for i in range(0, int(self.numOfDivs)):
            param = (maxDom-minDom)/self.numOfDivs * i

            pt = rs.EvaluateCurve(self.curve,  param)
            tan = rs.CurveTangent(self.curve, param)
            if i < 1:
                tan = rs.VectorScale(rs.CurveTangent(self.curve, param), -self.radius*2)
            elif i == self.numOfDivs-1:
                tan = rs.VectorScale(rs.CurveTangent(self.curve, param), self.radius*2)
            else:
                tan = rs.VectorScale(rs.CurveTangent(self.curve, param), self.radius)

            tanPt = rs.PointAdd(tan, pt)
            #rs.AddLine(pt, tanPt)
            points.Add(tanPt)
        print "Before sort ..."
        for point in points:
            print "point: {0}".format(point)
        nc = Rhino.Geometry.NurbsCurve.Create(False, 1, points)
        rc = Rhino.Commands.Result.Failure
        if nc and nc.IsValid:
            if scriptcontext.doc.Objects.AddCurve(nc)!=System.Guid.Empty:
                scriptcontext.doc.Views.Redraw()
                rc = Rhino.Commands.Result.Success
        return rc

curve = rs.GetObject("Select a curve")
obj = TanLines(curve, rs.GetReal("length", 200, 0, 10000), rs.GetReal("Radius", 200, 0, 10000))
obj.tanPoints()

Kind regards,
and please let this be a dialogue :slight_smile: