Welcome, Guest. Please login or register.
Did you miss your activation email?
February 13, 2012, 04:15:38 AM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  Feature Requests
| | |-+  Find tool command for running gcode.
Pages: 1   Go Down
Print
Author Topic: Find tool command for running gcode.  (Read 691 times)
0 Members and 1 Guest are viewing this topic.
glengeniii
Active Member

Offline Offline

Posts: 26


View Profile
« on: December 21, 2009, 06:07:54 PM »

On some cnc machines I have ran,  there was an option called find tool.  This command would search the gcode for the tool you specify, thus giving you the option of run the program from that point.  It saves a lot of time if you need to start from a specific tool change point when the program have 40,000 lines of code.
Logged
zealous
Active Member

Offline Offline

Posts: 486



View Profile WWW
« Reply #1 on: December 29, 2009, 03:46:31 AM »

Great thing about Mach is you can do about anything you want!

Always take precaution when running code and attempt to break it so later it doesn’t happen unexpectedly!!!

1.Place this code on a button or Macro.
2.Make sure you are in a "Stop" condition
3.Run script

The script finds the next M6/M06 from your "Currently Line" after which YOU WILL NEED TO either HIT RUN FROM HERE or SET NEXT LINE. Depending on your needs I did not want to add that in.

Recap this script should only be run when in a stop condition and will only find the next M6/M06 from your current position in the file.

If you find any issues let me know, but use at your own discretion.

Code:
Dim currentfile As String
Dim filesys, filetxt, lastline, oldline As String
Dim currentLine As String
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set filesys = CreateObject("Scripting.FileSystemObject")
currentLine = GetOEMDRO(816)
Found = False
currentfile = FileName
Set filetxt = filesys.OpenTextFile(currentfile, ForReading, True)
Dim i As Integer
i = 0
Do While filetxt.AtEndOfStream <> true
linestring = UCase(filetxt.ReadLine()) & " "
If linestring <> " " Then
i = i+1
If i > currentLine Then
If ((InStr(linestring,"M6") >0 Or InStr(linestring,"M06")>0)) Then
SetOEMDRO(816,i)
Found = True
MsgBox "File has been set to line:"& GetOEMDRO(816)&" Your next toolchange position.Your previous line was:"&currentLine
Exit Do
End If
End If
End If
Loop
If Found = False Then
MsgBox "No M6/M06 Found after LINE:"& currentLine
End If
filetxt.Close
Set filesys = Nothing
Set filetxt = Nothing

Have fun!
Thanks Jason Blake
Logged

Regards, Jason Blake

www.Fusioncnc.com
Pages: 1   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!