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.
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.
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.
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.