Hello Guest it is April 16, 2024, 10:44:24 AM

Author Topic: Mach4 button to load GCode file  (Read 3523 times)

0 Members and 1 Guest are viewing this topic.

Mach4 button to load GCode file
« on: March 22, 2017, 10:11:49 AM »
Want to make a button to load a specific GCode file in Mach4. Can't seem to get the code correct. Help please.

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Mach4 button to load GCode file
« Reply #1 on: March 22, 2017, 03:33:59 PM »
Why not post your code?? then perhaps we can see whats not correct and help to get it correct.

DazTheGas
New For 2022 - Instagram: dazthegas
Re: Mach4 button to load GCode file
« Reply #2 on: March 22, 2017, 04:59:25 PM »
I using m122 to prove the code before I put it in a Button.
Not sure if line 3 is correct. The path for the file is.   C:\Mach3\GCode\CHRIS.txt
If I put the whole path in place of just CHRIS.txt I get a compile error.
My goal is to have a button to load the only program the machine will ever run.

1.    function m122()
2.    Local inst = mc. mcGetInstance();
3.    mc. mcCntlLoadGcodeFile(inst, CHRIS.txt);
4.    end
5.    if ( mc. mcInEditor() == 1) then
6.     m122()
7.     End

« Last Edit: March 22, 2017, 05:06:06 PM by Acrodoc »

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Mach4 button to load GCode file
« Reply #3 on: March 22, 2017, 05:18:14 PM »
firstly to test a button script you really want to be editing a button not a macro, line 2 and 3 is all you will need in the left up button script, the path and name of the file needs to be in quotes.

DazTheGas
New For 2022 - Instagram: dazthegas
Re: Mach4 button to load GCode file
« Reply #4 on: March 22, 2017, 06:29:41 PM »
OK I created the button and in the Left Up Script

1.  local inst = mc.mcGetInstance();
2.  mc.mcCntlLoadGcodeFile(inst, "CHRIS.txt");

It still does not work. Please type it as it should be. Thank you

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Mach4 button to load GCode file
« Reply #5 on: March 23, 2017, 02:14:52 AM »
if your gcode is in mach3 directory then you need to add the path too

Code: [Select]
local inst = mc.mcGetInstance()
mc.mcCntlLoadGcodeFile(inst, "C:\\Mach3\\GCode\\CHRIS.txt")

DazTheGas
New For 2022 - Instagram: dazthegas
Re: Mach4 button to load GCode file
« Reply #6 on: March 23, 2017, 10:45:23 AM »
DazTheGas that worked. I tried everything but doubling up the back slash.
Could you recommend any documentation I could download and read and use as reference so I could work through these problems better on my own. I have watched your videos and they have definitely helped. I can write GCode very well and have done a fair amount of Ladder writing. The VB Scripting for Mach3 is pretty basic so I was fair at that but this LUA is more powerful but also more difficult for someone with no coding experience.

Thanks again for all your help.

Offline DAAD

*
  •  103 103
    • View Profile
Re: Mach4 button to load GCode file
« Reply #7 on: March 03, 2020, 05:54:02 AM »
My first post on here.

I'm trying to find my way in mach and would like to add a button that leads to a script as above.
I do not have any experience with coding, so please keep in mind.

I've already added a new tab and new button in my screenset. Now i want to add the script as above trough the interface via the left up script.
If i put in the script in the zerobrane interface and save the script, the script does not how up in the action besides the left up script.

Can someone help me out?

Just would like to have acces trough some buttons to run gcode i frequently use.

Thanks in advance

Daad