Hello Guest it is April 19, 2024, 09:53:40 PM

Author Topic: List of Tools used in a Part Program  (Read 6280 times)

0 Members and 1 Guest are viewing this topic.

List of Tools used in a Part Program
« on: January 04, 2011, 09:14:16 PM »
When Mach is loading the G Code program, it seems to parse the program to produce the graphic display. I would like to have Mach produce a list of tools used. This list could be created while the G code program is being loaded. This list would be accessed by a menu item and would list the tool number and at least the description from the tool table. 
     This list could be used by the operator to be sure that all of the tools are available and ready to go.

Offline zealous

*
  •  489 489
  • HI!
    • View Profile
    • Artsoft Solutions
Re: List of Tools used in a Part Program
« Reply #1 on: January 10, 2011, 06:23:48 AM »
Hello,
Simply change your "Load Gcode" button to "VBScript" and past this code, or if you would like to call on it to read the current file with out the navigation remove:

Code: [Select]
DoOEMButton(216)
While(isloading)
sleep(250)
Wend

This code will:
1. Open a file navigation to open Gcode in Mach
2. Look for "M6/M06" and the "T" value
3. Write a file called "StoredM6.txt" in the current directory
4. "StoredM6.txt" will contain: Inc M6 call,  Line Number, Tool Number, Name, Diam and Length.
5. Open the text file
If there are no M6's it will display a message.

Code: [Select]
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim filesys, filetxt, lastline,oldline,Stored_List,StoreFilePath,path,currentfile As String
Dim dTaskID As Double
Dim i,k,j As Integer

DoOEMButton(216)
While(isloading)
sleep(250)
Wend

StoreFilePath = CurDir & "\StoredM6.txt"
path = "C:\WINDOWS\notepad.exe"
Found = False
Stored_List = ""
currentfile = FileName
i = 0
k = 0
j=0

Set filesys = CreateObject("Scripting.FileSystemObject")
Set objTextFile = filesys.CreateTextFile(StoreFilePath)
Set filetxt = filesys.OpenTextFile(currentfile, ForReading, True)



Do While filetxt.AtEndOfStream <> true

linestring = UCase(filetxt.ReadLine()) & " "

If linestring <> " " Then
k = k+1
If ((InStr(linestring,"M6") >0 Or InStr(linestring,"M06")>0)) Then

Found = True
j = j+1
ToolIndex = InStr(linestring,"T")

For d = 3 To 0 Step -1

ToolNum = Mid(linestring,ToolIndex+1,d)

If IsNumeric(ToolNum) Then

N = GetToolDesc(ToolNum)
D = GetToolParam(ToolNum,1)
L = GetToolParam(ToolNum,2)

Exit For
End If
 Next d
 
 i = i+1

objTextFile.WriteLine( j & " Line# " & k & " Tool# " & ToolNum & " Name: " & N & " Diam: " & D & " Length: " & L)

End If

End If

Loop



If Found = True Then
dTaskID = Shell(path + " " + StoreFilePath, vbNormalFocus)
Else
MsgBox "No M6/M06 Found"
End If

filetxt.Close
Set filesys = Nothing
Set filetxt = Nothing
objTextFile.Close







« Last Edit: January 10, 2011, 06:27:39 AM by zealous »

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: List of Tools used in a Part Program
« Reply #2 on: January 10, 2011, 04:26:50 PM »
Very handy Jason, hopefully one day Turn will get sorted and be able to make use of this as well.
Hood

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: List of Tools used in a Part Program
« Reply #3 on: January 10, 2011, 07:15:37 PM »
That would be a handy item for the Mach tool box (;-)

Good Job Jason, (;-) TP
Re: List of Tools used in a Part Program
« Reply #4 on: January 10, 2011, 08:23:49 PM »
Much Thanks.  I tend to run programs with lots of different tools and this really helps.

Offline zealous

*
  •  489 489
  • HI!
    • View Profile
    • Artsoft Solutions
Re: List of Tools used in a Part Program
« Reply #5 on: January 13, 2011, 06:00:10 PM »
I am so glad that you can use the code and it is useful  :)
I commented the code and cleaned it up a bit, I also fix the code to correctly show the "Line Number" the M6/M06 was on.

Would it help to have a "Show Next Tool" while running the machine? So you know what tool is coming up next in the Gcode?

Code: [Select]
'Define vars
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim filesys, filetxt, lastline,oldline,Stored_List,StoreFilePath,path,currentfile As String
Dim dTaskID As Double
Dim i,k,j As Integer

'Bring up File navigation
DoOEMButton(216)
While(isloading)
sleep(250)
Wend

'paths
StoreFilePath = CurDir & "\StoredM6.txt"
path = "C:\WINDOWS\notepad.exe"
currentfile = FileName

'Default values
Found = False
i = 0
k = -1
j=0

'File System Create objects
Set filesys = CreateObject("Scripting.FileSystemObject")
Set objTextFile = filesys.CreateTextFile(StoreFilePath)
Set filetxt = filesys.OpenTextFile(currentfile, ForReading, True)


'Read File
Do While filetxt.AtEndOfStream <> true
linestring = UCase(filetxt.ReadLine()) & " "

'Uppercase check if not emptyLine
If linestring <> " " Then

'Count Line Number
k = k+1

'Is there a M6 or M06
If ((InStr(linestring,"M6") >0 Or InStr(linestring,"M06")>0)) Then

'Tells if we should open Notpad
Found = True

'Count Number of M6 M06
j = j+1

'Find index of T
ToolIndex = InStr(linestring,"T")

'Count backwards till we get a number
For d = 3 To 0 Step -1

ToolNum = Mid(linestring,ToolIndex+1,d)

'Is it a number then we know the tool#
If IsNumeric(ToolNum) Then

'Set the values of the tool
N = GetToolDesc(ToolNum)
D = GetToolParam(ToolNum,1)
L = GetToolParam(ToolNum,2)

Exit For
End If
 Next d
 
 
'Write values to StoredM6.txt
objTextFile.WriteLine( j & " Line# " & k & " Tool# " & ToolNum & " Name: " & N & " Diam: " & D & " Length: " & L)

End If
End If
Loop


'If a M6 was found then open up notpad with the new values
If Found = True Then
dTaskID = Shell(path + " " + StoreFilePath, vbNormalFocus)
Else
MsgBox "No M6/M06 Found"
End If

'Close and release everthing
filetxt.Close
Set filesys = Nothing
Set filetxt = Nothing
objTextFile.Close

Offline rcaffin

*
  •  1,054 1,054
    • View Profile
Re: List of Tools used in a Part Program
« Reply #6 on: February 06, 2011, 07:54:05 PM »
On an allied note: it would be extremely nice if we could edit, reload or change the tool  table in Mach3Lathe.

To explain: I have several multi-tool mounting blocks. I can calibrate each one and save the tool table. I can even add a descriptor for each tool (T101 to T9999 etc) in the text field, like 'tipl 3 position 2'. Yes, I can rename/save each tool table after I have done the calibration.

But what I cannot do at present is to edit a tool table (tools3.dat) off-line to create a new tool table for a job, putting the appropriate parameters into each tool line. That would let me create a new tool table for a job appropriate to the combination of tips I propose to use.  Well, I guess I could but that would mean doing a very messy binary edit of tools3.dat.

What might work almost as well would be to simply change the format of tools3.dat from binary to ASCII. There is NO reason any more to ever use a binary data file: UNIX and LINUX do not.

Hum?

Cheers
Roger

Offline zealous

*
  •  489 489
  • HI!
    • View Profile
    • Artsoft Solutions
Re: List of Tools used in a Part Program
« Reply #7 on: February 06, 2011, 09:44:44 PM »
Quote
There is NO reason any more to ever use a binary data file
I second this %110.
No need to protect this data put it in the XML
*One thing you can do for now is store the data in a text file and onload of Mach write to these values or on a button push.
« Last Edit: February 06, 2011, 09:46:35 PM by zealous »

Offline rcaffin

*
  •  1,054 1,054
    • View Profile
Re: List of Tools used in a Part Program
« Reply #8 on: February 06, 2011, 10:03:28 PM »
Not keen on requiring the user to edit the XML. OK for someone with a CS degree, but not so nice for someone who has come from the hobby or workshop direction.

I suggest that it should be in two parts:
* A menu option to load/save tool table X (different one for each job)
* The tool table in ASCII not binary

Neither of these require any significant change to the structure of Mach - which makes implementing it very easy.

Cheers