Hello Guest it is March 29, 2024, 09:57:10 AM

Author Topic: Using G-code files in Button Scripts  (Read 24898 times)

0 Members and 1 Guest are viewing this topic.

Using G-code files in Button Scripts
« on: August 12, 2011, 02:06:16 PM »
I am just getting into screen customization and writing script for buttons.  Looking at the Programmer's Reference Manual it should be possible to load and run G-code files using the LoadFile() then RunFile() commands so that hitting the button will cause that piece of code to be executed.  The files given in the example are .TAP files and I see that the Wizard files stored in the GCode directory of Mach3 are in that format.  The G-code files created normally (using Notepad) are in the .TXT format and although it is possible to load these files and they will run and do some things, the commands that should make the axes move do not function.

Should this approach work? do I need to generate .TAP files and if so how? or am I completely out to lunch with this approach?

Help would be appreciated

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Using G-code files in Button Scripts
« Reply #1 on: August 12, 2011, 04:03:22 PM »
The .tap/.txt extension will not make a diiference as long as MACH will except it. There is a list in the manual .

Are you refereing to the GCODE Programs or Macro programs. Gcode Programs can ONLY run Gcode commands. A macro program can be a mix of Gcode and MachCB.

Can you post an example ?

(;-) TP
Re: Using G-code files in Button Scripts
« Reply #2 on: August 12, 2011, 05:17:12 PM »
I was surprised to find that none of the examples in the Programmers Reference actually work. They all fail on my machine! LoadRun(File) stalls on generating the toolpath. The LoadFile(Filename), RunFile() example does not work because it executes way too fast. RunFile() is executed while LoadFile is still working. The IsLoading() example doesn't work because IsLoading() goes false early, before LoadFile() is complete, or at least before Mach is ready for a Cycle Start. Here is an example that will work for sure. I'm running 3.043.022, but that shouldn't matter.

LoadFile("D:\Mach3\GCode\roadrunner.tap")
' Wait for Load to Complete
Do
   Sleep 100
Loop While IsLoading()     'Wait until LoadFile reports that it is done.
Sleep(100)     'Extra sleep time to allow LoadFile to actually be complete
' Run the File
RunFile()
Re: Using G-code files in Button Scripts
« Reply #3 on: August 12, 2011, 05:25:38 PM »
In regards to notepad, you may have to change the file type to "All Files (*.*)" for it to "Save As..." an extension other than .txt when writing from scratch. If it already has a different extension and you just hit "Save", it wouldn't change the extension, but otherwise it wants to make it .txt by default.

Give that a try.

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Using G-code files in Button Scripts
« Reply #4 on: August 12, 2011, 08:12:39 PM »
ALSO MAch does not CARE about the extention name It can be anything other than a control extention such as exe,dll,com,etc

As long as the content is Gcode it can read and run it.

(;-0 TP
Re: Using G-code files in Button Scripts
« Reply #5 on: August 12, 2011, 08:18:05 PM »
Nice to know the exact extension limitations. Thanks.

Chris

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Using G-code files in Button Scripts
« Reply #6 on: August 12, 2011, 08:37:59 PM »
All of the programmers guide examples do work



LoadFile("D:\Mach3\GCode\roadrunner.tap")
 While IsLoading()     'Wait until LoadFile is done.
Wend
RunFile()

OR JUST

LoadRun("D:\Mach3\GCode\roadrunner.tap")

(;-) TP
Re: Using G-code files in Button Scripts
« Reply #7 on: August 12, 2011, 09:19:42 PM »
OK, I'll check on another machine. I only said I was surprised that they weren't working on my machine. This is a quad-core on Win7 64bit so that may be my problem. If that's it then it's the first script problem I've noticed on this configuration.

Thanks for confirming.

Chris

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Using G-code files in Button Scripts
« Reply #8 on: August 12, 2011, 09:42:22 PM »
32 bit is the standard.

(;-) TP

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Using G-code files in Button Scripts
« Reply #9 on: August 12, 2011, 09:58:32 PM »
A lot of things don't work properly without the PP driver installed, and it doesn't work on 64 bit.

I've found that just testing new screens without the driver installed resulted in a lot of things not working correctly.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html