A recent post showing that SpindleSpeed didn't get transferred from a Milling.MillTool to the toolpath Tool() got me to thinking how to slim down the copying of the MillTool values over to the Tool() fields when creating the toolpaths to avoid such errors. (That and I needed such a function for my own V-Carve Last Pass gadget if I ever finish it.)
In EasyBoxMaker v2.0, around line 2038, there is this 13 lines of code:
Code: Select all
local tool = Tool(Milling.MillTool2.Name, Tool.END_MILL)
tool.InMM = Milling.MillTool2.InMM
...
-- tool.VBitAngle = Milling.MillTool2.VBitAngle
-- tool.ClearStepover = Milling.MillTool2.ClearStepover
Code: Select all
local tool = Tool(Milling.MillTool2.Name, Tool.END_MILL)
tool = loadToolValues(Milling.MillTool2, tool, readOnlyKeys)
1. The following function:
Code: Select all
function loadToolValues(source, destination, excluded)
local toolToLoad = destination
for key, value in pairs(source) do
if not excluded[key] then
toolToLoad[key] = value
end
end
return toolToLoad
end
Code: Select all
readOnlyKeys = {
["Name"] = true, ["RateUnitsText"] = true,
["ToolDBId"] = true, ["ToolDB_Location"] = true,
["ToolType"] = true, ["ToolTypeText"] = true
}
This will shorten the code by quite a bit and hopefully make it easier to maintain. Note that the field key namess in Milling.MillTool{n} tables need to match those in the Vectric SDK Tool() object.
By the way: xxx.VBitAngle (both the Vectric Tool() instances and the MillTool ones) need to be changed to VBit_Angle everywhere or you will always get a bit of 90 degrees. V-Bits don't appear to be used in the Box Maker Gadget but it's good to change it in case this sort of code is re-used in another gadget that does use v-bits or engraving bits.
Attached is a sample Lua file that loads two tools and creates a sample profile toolpath for each.
Note that going from a Vectric tool to the Milling.MillTool is possible to. We just need the following minimum exclusion table:
Code: Select all
excludedKeys = {
["ToolDBId"] = true, ["ToolDB_Location"] = true
}
Code: Select all
["Name"] = true,
Steven