Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 12:54:01 AM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  VB and the development of wizards
| | |-+  Using G-code files in Button Scripts
Pages: 1 2 3 4 5 »   Go Down
Print
Author Topic: Using G-code files in Button Scripts  (Read 2174 times)
0 Members and 1 Guest are viewing this topic.
CNCSarnia
Active Member

Offline Offline

Posts: 14


View Profile
« on: August 12, 2011, 01: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
Logged
BR549
Active Member

Offline Offline

Posts: 2,557


View Profile
« Reply #1 on: August 12, 2011, 03: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
Logged
Sargon
Active Member

Offline Offline

Posts: 99


View Profile
« Reply #2 on: August 12, 2011, 04: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()
Logged
Sargon
Active Member

Offline Offline

Posts: 99


View Profile
« Reply #3 on: August 12, 2011, 04: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.
Logged
BR549
Active Member

Offline Offline

Posts: 2,557


View Profile
« Reply #4 on: August 12, 2011, 07: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
Logged
Sargon
Active Member

Offline Offline

Posts: 99


View Profile
« Reply #5 on: August 12, 2011, 07:18:05 PM »

Nice to know the exact extension limitations. Thanks.

Chris
Logged
BR549
Active Member

Offline Offline

Posts: 2,557


View Profile
« Reply #6 on: August 12, 2011, 07: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
Logged
Sargon
Active Member

Offline Offline

Posts: 99


View Profile
« Reply #7 on: August 12, 2011, 08: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
Logged
BR549
Active Member

Offline Offline

Posts: 2,557


View Profile
« Reply #8 on: August 12, 2011, 08:42:22 PM »

32 bit is the standard.

(;-) TP
Logged
ger21
Global Moderator
*
Offline Offline

Posts: 2,619



View Profile WWW
« Reply #9 on: August 12, 2011, 08: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.
Logged

Pages: 1 2 3 4 5 »   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!