Author Topic: Drag-Knife Script  (Read 128532 times)

Offline billt

  • Droid
  • **
  • Posts: 90
    • View Profile
Drag-Knife Script
« on: October 03, 2013, 03:00:27 am »
Adding drag-knife functionality to CAMBAM!
This will be useful for all of us messing with cutting vinyl, wood veneer, cardboard...

This Python script takes selected polylines and generates new polylines used for the drag-knife tool path.
From the tool path polyline, an engrave MOP must be used to create the actual tool path and G-code.
Extract the file drag_knife.py from the attached ZIP file and save it into your "Scripts" directory.

Without compensation, sharp corners are rounded due to the drag-knife tip offset.
This script adds "corner features" which includes an overcut and swivel arc to the next cut segment.
Also added is a "retract" feature at the corners which retracts during the swivel motion for thick materials.
Note, the blade must be oriented toward the +X direction which allows the first point to be precisely located.
These features are well described at: www.DonekTools.com

Also featured is support for the knife tip to exactly follow arc paths.
The concept is based on bicycle front/rear wheel paths.
The "front wheel" is driven by the machine engrave path, and the knife tip is the "rear wheel".
The tool offset (distance from the tool centerline to knife tip) correlates to the bike wheelbase.
Formulas for bike wheel path are found at:  http://math.ucsd.edu/~ebender/87/bicycle.pdf

The script works in concept, however the polyline start/end points can create a problem with cut results.
I tested using a modified Cricut holder (with blade auto-spring!), 2mm blade has a very small .009" offset.
I guess my machine has poor resolution, and the tiny arc paths did not orient the blade exit correctly.
This resulted in some start/end corners that were not perfect and did not release free.
Picking the start/end points in the middle of a horizontal section would give better results.
Although CAMBAM does not make it easy to select the polyline start point...
I am now working on Rev 2 which will attempt to find a good start point, and make all cuts CCW.

Also of interest, I will be posting soon my DIY drag-knife tool designs.
Several options should get you going hopefully for under $20.
I have on order two other Roland blade holders for modifications: spring feature and hold in a 1/2" collet.
Also a potential X-Acto drag-knife design which should work well for thicker material like cardboard.

By the way, if anyone is willing to make this into a Plugin, that would be awesome!

Cheers - BillT
« Last Edit: October 06, 2015, 00:34:08 am by billt »

Offline billt

  • Droid
  • **
  • Posts: 90
    • View Profile
Re: Drag-Knife Script
« Reply #1 on: October 03, 2013, 03:08:29 am »
If a plugin could be created, a helpful feature would be to slow the tool speed down for the corner features.
A related "Quality" setting on some vinyl cutters affects the acceleration speed in/out of corners.
This would help the quality of corner cuts.
Cheers - BillT

Offline Bubba

  • CNC Jedi
  • *****
  • Posts: 3355
    • View Profile
Re: Drag-Knife Script
« Reply #2 on: October 03, 2013, 21:47:22 pm »
If a plugin could be created, a helpful feature would be to slow the tool speed down for the corner features.
A related "Quality" setting on some vinyl cutters affects the acceleration speed in/out of corners.
This would help the quality of corner cuts.
Cheers - BillT


Did you considered a 'Exact stop' settings. I believe it would help with corners..
My 2ยข

Win11, CB(1.0)rc 1(64 bit) Mach3, ESS, G540, 4th Axis, Endurance Laser.

Offline billt

  • Droid
  • **
  • Posts: 90
    • View Profile
Re: Drag-Knife Script
« Reply #3 on: October 05, 2013, 02:10:08 am »
Thanks for the tip.
I will try this out and let you know if it improves the corners.
 - BillT

Offline Dragonfly

  • CNC Jedi
  • *****
  • Posts: 2652
    • View Profile
Re: Drag-Knife Script
« Reply #4 on: April 20, 2014, 11:36:10 am »
Here's my take on making a holder which holds a Roland type knife holder :)
And it works to my surprise.
There are two problems, however. Both related to knife tip offset.
1. Corners - simplest check is a right corner - because the edge lags behind (0.25 mm for that knife) at the turning point it has still not cut the material to the corner. Therefore a small arc is cut in practice before the knife pivots itself on the perpendicular line.
2. Closed shapes not cut - again a classic G-code program stops at where the tool axis is but the knife is a bit behind and there is a tiny distance of uncut material left which hampers the consequent removal of waste material.

The factory cutting plotters have this value settable and their software accounts for it.

Otherwise the spring force is adjusted by Z-height and DOC by the adjusting cap leaving just enough of the blade protruding.
But the Chinese Roland type holder clone I got is manufactured with quite loose tolerances so that the adjustment cap is shaking on its thread.

Offline billt

  • Droid
  • **
  • Posts: 90
    • View Profile
Re: Drag-Knife Script
« Reply #5 on: April 21, 2014, 01:27:35 am »
Dragonfly -
I was also able to modify a Roland-style cutter, and it provides spring force adjustment screw.
See the topic http://www.cambam.co.uk/forum/index.php?topic=3667.0

Your post is not clear - did you use the drag knife script from my earlier post to modify your cut path?
I believe that this would fix your corner and end point issues.
It is not a plugin, but can be loaded to you Scripts directory, select the paths, then run the script.
New paths with corner over-cut features are created to compensate for the drag knife offset.
You will need to update your knife offset value in the script itself before running.

BTW I recently bought a Silhouette Portrait for a little over $100.
It is a small machine that cuts up to 8 inches wide, and works really well for small vinyl projects.
The software is free and really good for artistic 2D stuff, but does not do 2.5D or export g-code.
I found that you can fake an export by printing to PDF then converting to dxf.
So... I have not made any improvements to the script since the initial release.

Cheers - BillT

Offline Dragonfly

  • CNC Jedi
  • *****
  • Posts: 2652
    • View Profile
Re: Drag-Knife Script
« Reply #6 on: April 21, 2014, 11:21:57 am »
I haven't tested your script yet, just downloaded it. First I wanted to see whether I got right the concept of how a cutting plotter knife works. I tried on a piece of some domestic adhesive foil whose backing is quite thin and it still worked. Tomorrow I'll get a piece of real vinyl foil for testing.

As I mentioned the quality of the Chinese knife holder is poor (at least to me) and it appears there is only one bearing to support the knife. So, with a friend of mine who has a small precise lathe, we decided to make a holder of our own and with all metric threads.

The picture you posted in the other thread is not very clear but it seems there are differences in construction although external body shape is the same. Wen I remove the hollow screw at the back nothing comes out. It seems the spring and magnet are inserted from the front and then the bearing is press fitted into the body. My main problem is that the knife protrudes too far over the cap even with the set screw removed and this requires unscrewing the adjusting cap too much so it starts to shake loosely.
« Last Edit: April 21, 2014, 11:33:49 am by Dragonfly »

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 8969
    • View Profile
Re: Drag-Knife Script
« Reply #7 on: April 21, 2014, 12:41:39 pm »
Bill,
For scheduling, I cannot attend to it now, but that looks to be an easy script to make into a plugin.

If someone doesn't get to it before I do, I'll do that as soon as I get this current (pressing) project out.

LLoyd
"Pyro for Fun and Profit for More Than Fifty Years"

Offline Dragonfly

  • CNC Jedi
  • *****
  • Posts: 2652
    • View Profile
Re: Drag-Knife Script
« Reply #8 on: April 21, 2014, 13:25:47 pm »
I just tried the script on a shape I used to test the cutting.
It creates a new poly so it's better to have a new empty active layer ready.
The new path looks like what I've seen in a Roland plotter user manual I downloaded and read. Haven't tried to go into the code  but I am impressed.
With red circles I've marked the small corrections along the long irregular curves.
In the yellow circle and zoomed is what I consider an intentionally created start point with the original closed shape broken at the same spot. Am I right in my conclusion?

Offline billt

  • Droid
  • **
  • Posts: 90
    • View Profile
Re: Drag-Knife Script
« Reply #9 on: April 22, 2014, 14:16:34 pm »
Dragonfly -
You are correct, the feature that you circled and zoomed is the first point of your polyline path.
The script expects that the knife tip is manually oriented toward the +X direction.
Your start segment is not horizontal, so the first tool point is offset to the +X by the knife offset value, and then swivels toward the direction of the first path segment.
Note also at the end of the path, the tool will swivel back to +X to prepare for the next polyline.

LLoyd - Thanks for offering to pluginize my creation!
I will watch for updates and will look forward to testing it out.

This start point could be improved or automated for better results, but I have not gotten around to it yet.
 - The script could search for a horizontal segment in the polyline to set the start point in the middle of the segment.  Then a swivel at the beginning and end of the path would not be necessary.  It should give a cleaner cut.  It might also help to do a slight overcut of the end point to make sure that the material is fully cut through.
 - Or, I notice as I watch my Silhouette machine that it does a quick slice in the top corner of the material in a "waste" area to orient the knife prior to cutting the first path.  This would be easy to program, just determine the direction of the first cut segment.  In this case the knife would not need to be manually oriented.  Maybe as a plugin a checkbox could select whether the user wants to manually orient in +X, or do an automated slice in a waste zone.

Cheers - BillT

Offline Dragonfly

  • CNC Jedi
  • *****
  • Posts: 2652
    • View Profile
Re: Drag-Knife Script
« Reply #10 on: April 22, 2014, 18:48:27 pm »
Bill,
I am looking at the script code but understand too little of it. Especially because I have no idea about CB API functions and objects.
Is there a way to make it adjust and compensate only real corners and not to make the tiny dents along the curved shapes. I don't need that accuracy for what I intend to do and they disrupt the constant velocity mode.
Also I think it would be useful if it is possible to make the cut overlap between start and end a bit larger. Still there are tiny uncut spikes.
Maybe because the actual knife offset is too small - 0.25 mm.

Offline billt

  • Droid
  • **
  • Posts: 90
    • View Profile
Re: Drag-Knife Script
« Reply #11 on: April 22, 2014, 20:36:13 pm »
The script function does follow curves exactly.
The location of the "tiny dents" that you have circled in red are at points where polyline segments meet at an angle larger than the value specified by the variable "SwivelAngle" that you can set at the beginning of the script.
The default value is set to 40 (degrees).
If you have a low precision part a better value to try might be 89 (degrees) - you will find that your "tiny dents" on the curved segments will no longer be created.

You are correct, there is currently no overcut at the start/end point.
As I mentioned previously, this would be a good feature to add in a future revision.
You might be able to fake it by using a smaller than actual value for the Offset, although this might affect your precision at the corners.

By the way, you need to use half the width of the knife for the Offset value since this is the distance from the centerline of the knife to the knife tip.  So if measuring the knife with calipers gives 0.25mm use 0.125mm for the Offset value.  Maybe this will correct your uncut end points?

Let me know how you make out with these suggestions.

Cheers - BillT

Offline Dragonfly

  • CNC Jedi
  • *****
  • Posts: 2652
    • View Profile
Re: Drag-Knife Script
« Reply #12 on: April 23, 2014, 08:47:04 am »
Thanks for your assistance. It appears I have misunderstood the usage of the '"Swivel Angle" variable :)

Offline Dragonfly

  • CNC Jedi
  • *****
  • Posts: 2652
    • View Profile
Re: Drag-Knife Script
« Reply #13 on: April 23, 2014, 17:31:02 pm »
Interesting. This simple shape I drew from a rectangle and a circle just for testing causes "division by zero" error at line 83 -> V2.X = 0.
But that's all I can tell at the moment.

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 8969
    • View Profile
Re: Drag-Knife Script
« Reply #14 on: April 23, 2014, 19:25:52 pm »
Those are easy to fix.  I'll let Bill modify it until everyone is happy, before I tackle plugin-izing it. :)

Lloyd
"Pyro for Fun and Profit for More Than Fifty Years"