Hello Guest it is March 28, 2024, 10:00:42 PM

Author Topic: Export tool table  (Read 5826 times)

0 Members and 1 Guest are viewing this topic.

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Export tool table
« Reply #10 on: May 15, 2014, 11:37:28 PM »
oK I added the date/time to the top of the report and reformated for IMP units AND added a blurb to the status bar to let you know it is finished AND sent it direct to notepad for viewing.

What I cannot figure out is HOW to Multiply the DIAM value *2. Nothing I have tried works.

(;-) TP

Offline Bodini

*
  •  216 216
    • View Profile
Re: Export tool table
« Reply #11 on: May 15, 2014, 11:40:25 PM »
Followed corrections/suggestions by TP.  Version 2. (or would that be 1.0.0.1 or something like that?)   :D

Code: [Select]
--Version 2
file = io.open("tool table.txt","w") -- open a new current file
file:write("Mach 4 Tool table\n\n")
file:write(string.format("Tool#        Length   Length Wear     Dia   Dia Wear    Description\n"))

inst = mc.mcGetInstance()
var1 = 7780 --start number
var2 = 10319 --end number
var3 = 10 --increment
local toolno = 1

for outer = var1, var2 ,var3 do
    c1 = outer + 5 --length
    c2 = outer + 6 --Length wear
    c3 = outer + 8 --dia
    c4 = outer + 9 --dia wear

    w1 = mc.mcCntlGetPoundVar(inst, c1)
    w2 = mc.mcCntlGetPoundVar(inst, c2)
    w3 = (mc.mcCntlGetPoundVar(inst, c3)*2)
    w4 = (mc.mcCntlGetPoundVar(inst, c4)*2)
    desc= mc.mcToolGetDesc(inst, toolno)
        ootput1 = string.format("Tool#%d   %10.2f %10.2f %10.2f %10.2f    %s\n",toolno,w1,w2,w3,w4,desc)
        ootput2 = string.format("Tool#%d   %9.2f %10.2f %10.2f %10.2f    %s\n",toolno,w1,w2,w3,w4,desc)
        ootput3 = string.format("Tool#%d   %8.2f %10.2f %10.2f %10.2f    %s\n",toolno,w1,w2,w3,w4,desc)
if w1 > 0 then
if toolno >= 100 then
file:write(ootput3)
elseif toolno >=10 then
file:write(ootput2)
else
file:write(ootput1)
end
end
        var1 = var1+10
toolno = toolno + 1
   end
 file:write ("\n")  
 file:write(os.date("Created: %x  %X"))
 file:close() -- close current file
« Last Edit: May 15, 2014, 11:47:29 PM by Bodini »

Offline Bodini

*
  •  216 216
    • View Profile
Re: Export tool table
« Reply #12 on: May 15, 2014, 11:41:53 PM »
Oops, we crossed paths there. ha!  look for vars w3 and w4.

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Export tool table
« Reply #13 on: May 16, 2014, 12:08:56 AM »
I found my problem it was a FAT finger typing. I learned some LUA from SheetCam and Les has a different style for function names "File Name" in sheetcam is "fileName" where the second sylible starts with a CAP N.

Took me forever to get that in the brain NOW I have to figure out how to undo that habit.

I works great now. I also created a ToolTable export file to Import into SheetCam.  Now to see IF I can do the reverse and IMPORT a Scam tool table into Mach4.

Thanks for the example, (;-) TP