Dado Toolpath Creator gadget error found

This section is for general discussion about Gadgets
Post Reply
User avatar
adze_cnc
Vectric Wizard
Posts: 4325
Joined: Sat Jul 27, 2013 10:08 pm
Model of CNC Machine: AXYZ 4008
Location: Vancouver, BC, Canada

Dado Toolpath Creator gadget error found

Post by adze_cnc »

There is an error in the "Dado Toolpath Creator" gadget for version 11: https://gadgets.vectric.com/v11/dado_creator

It could cause problems if the tool and job are in different units of measure.

Code: Select all

local multiplier = 1
if tool.InMM and job.InMM == false then
  multiplier = 0.0254
end
if tool.InMM == false and job.inMM then
  multiplier = 25.4
end
The second "if" statement should have "job.InMM" rather than "job.inMM" (line 200 in the lua file).

User avatar
jimandi5000
Vectric Wizard
Posts: 1050
Joined: Wed Mar 11, 2015 6:50 pm
Model of CNC Machine: Home Made 60 x 120
Location: North Houston Tx.
Contact:

Re: Dado Toolpath Creator gadget error found

Post by jimandi5000 »

Hi Adze_cnc,

I agree the code has errors.

A better way to write this test is:

Code: Select all

local multiplier = 1
if tool.InMM and (job.InMM == false) then
  multiplier = 0.0254
else
  multiplier = 25.4
end
Thanks,
Jim

User avatar
adze_cnc
Vectric Wizard
Posts: 4325
Joined: Sat Jul 27, 2013 10:08 pm
Model of CNC Machine: AXYZ 4008
Location: Vancouver, BC, Canada

Re: Dado Toolpath Creator gadget error found

Post by adze_cnc »

Another error in that original two if statements is that the value 0.0254 is wrong. It should be 0.03937007874 as it is used to convert a tool diameter from mm to inches (e.g. 6.35 * 0.03937007874 = 0.25 which is correct).

0.0254 converts 1/1000s of an inch to millimeters e.g. 1000 * .0254 = 25.4

Jim,

You solution, while elegant doesn't quite work. It works if job and tool are different (TF or FT) but doesn't if job and tool are the same (TT or FF). When job and tool are the same the multiplier should be 1.

WIth yours TT and FF both give 25.4

User avatar
Adrian
Vectric Archimage
Posts: 14544
Joined: Thu Nov 23, 2006 2:19 pm
Model of CNC Machine: ShopBot PRS Alpha 96x48
Location: Surrey, UK

Re: Dado Toolpath Creator gadget error found

Post by Adrian »

Wow, that's a blast from the past. That's the first gadget I ever wrote many years ago. It was based on one of the first examples that Brian posted to the old testing forum before the LUA interface was publicly available so for the life of me I can't remember if that code was in the original or not but it's probably my error.

User avatar
adze_cnc
Vectric Wizard
Posts: 4325
Joined: Sat Jul 27, 2013 10:08 pm
Model of CNC Machine: AXYZ 4008
Location: Vancouver, BC, Canada

Re: Dado Toolpath Creator gadget error found

Post by adze_cnc »

For my first gadget that I just finished, still needs documentation, I tried to come up with my own way of implementing things That combined with learning Lua resulted in a bit of a spaghetti factory.

So, I went back to first principles and used Dado Creator as a model especially for the unit of measure conversions. It was while testing things that I noticed the errors.

User avatar
adze_cnc
Vectric Wizard
Posts: 4325
Joined: Sat Jul 27, 2013 10:08 pm
Model of CNC Machine: AXYZ 4008
Location: Vancouver, BC, Canada

Re: Dado Toolpath Creator gadget error found

Post by adze_cnc »

This does work:

Code: Select all

local multiplier

if tool.InMM and not job.InMM then
  multiplier = 0.0393700787401575
elseif not tool.InMM and job.InMM then
  multiplier = 25.4
else
  multiplier = 1
end
I suppose you could do "local multiplier = 1" and drop the last "else" but the code-style police probably would frown on that.

Post Reply