Hello Guest it is May 02, 2024, 12:18:16 AM

Author Topic: Load Gcode File not working in macro  (Read 262 times)

0 Members and 1 Guest are viewing this topic.

Load Gcode File not working in macro
« on: April 08, 2024, 09:11:05 AM »
Hi All,

I am trying to make a macro that allows me to dynamically edit GCODE. To do this, I am going to edit the GCODE in python and save the file to a directory, then reload it into Mach4 using a macro. I have written a test macro for the load GCODE part:

Quote
function m313()   --load gcode file
   
   local inst = mc.mcGetInstance() -- get mach4 instance
   mc.mcCntlCloseGCodeFile(inst)
   wx.wxMessageBox('Closed GCODE')
   
   local NextFileParen = "(C:\\Mach4Industrial\\Profiles\\CHAMP\\GCODE\\GCODEtoLoad.txt)"
   --wx.wxMessageBox(NextFileParen)
   
   local NextFile = string.gsub(NextFileParen, "[()%c%s]", "")
   wx.wxMessageBox('next file\n'..NextFile)
   
   wx.wxSleep(1) --gives Mach a second to do its thing
   
   mc.mcCntlLoadGcodeFile(inst, NextFile)
   
   wx.wxSleep(5) --gives Mach a second to do its thing
   
   mc.mcCntlCycleStart(inst)
         
end


if (mc.mcInEditor() == 1) then
   --dofile ("load_modules.mcs")
   m313()
end

When I run this macro within the ZeroBrane debugging tool, it appears to work fine. However, when I run it by calling the macro in gcode, it runs to end but does not actually load the GCODE. Anyone got any ideas why this may be/ any hints towards a solution?

Many thanks,
Dan

Offline Graham Waterworth

*
  • *
  •  2,673 2,673
  • Yorkshire Dales, England
    • View Profile
Re: Load Gcode File not working in macro
« Reply #1 on: April 08, 2024, 06:51:16 PM »
I do not see how that can work, all the internal code pointers will be screwed up.
Without engineers the world stops
Re: Load Gcode File not working in macro
« Reply #2 on: April 09, 2024, 03:07:55 AM »
I do not see how that can work, all the internal code pointers will be screwed up.

Hi Graham,
I'm not sure exactly what you mean by this but i will add that the newly loaded gcode file will begin at the current position in the old gcode.
Cheers,
Dan

Offline cncmagic

*
  •  63 63
  • what me worry? heck...it ain't my machine anyway
    • View Profile
Re: Load Gcode File not working in macro
« Reply #3 on: April 11, 2024, 10:33:34 PM »
sounds like some SCI-FI movie... as mankind wrecks havoc on earth.. a beautiful chemist, a by the book army major, a  programmer with mommy issues and and three fun loving astronauts fly the most sophisticated spacecraft ever developed into the unknown with the hope of finding a new planet... on the way, the chemist finds that all the food contains a strange chemical that's turning all the crew psychotic.. while trying  to determine where the chemical is coming from she falls in love with astronaut #2... however astronaut#1 is secretly in love with her and kills astronaut#3 by accident... meanwhile the programmer is a 'plant' from the earths major corporations who don't want anything to upset the stranglehold they have on earths dwindling resources.. while attempting to reprogram the spacecrafts computer he allows the programming code to edit itself.. and in turn 'Big Bertha' becomes self aware and also determines that all life must be extinguished.. starting with the crew.. any chance that the chemist is able to stop the major (who is also mad).. save her love before astronaut#1 kills him.. get the programmer to program her apple watch 3000maxi to connect to the ships main computer and destroy its cpu before the ship fly's into the sun? and still have time to get into the escape pod? self editing G-Code.. now that's something I never thought of... maybe Mach4 can make the parts it needs to kill everyone in the shop and then on to the town.. the city... the state.. can the beautiful sheriff's deputy (who's in love with the plants general manager) stop Mach4.. save the town before the giant Mach4 'battle-bot' kills everyone? ok.. I'm laughing too hard now.. time to leave.  :P
any semblance of information posted to anything remotely  close to accuracy is merely coincidence. Use at you own discretion.. or play the lottery.. same odds
Re: Load Gcode File not working in macro
« Reply #4 on: April 12, 2024, 04:36:45 AM »
Right, thanks cncmagic, very useful.

I will add that I am using Mach4 to control an additive manufacturing research platform. I am using in-situ sensing to dynamically adjust print parameters to create smart machinery. The problem here being our initial decision to use Mach4... the most stupid software ever built.
« Last Edit: April 12, 2024, 04:46:06 AM by mediumSasuage »

Offline cncmagic

*
  •  63 63
  • what me worry? heck...it ain't my machine anyway
    • View Profile
Re: Load Gcode File not working in macro
« Reply #5 on: April 12, 2024, 08:27:20 AM »
incorrect...on so many levels that I needed to go and have a beer and stop laughing... Mach4 does what its designed for well.. that is to run a cnc machine.. you know.. 2 axis.. 3 axis.. maybe more.. when you push it into area's it was not specifically designed for, by yourself (without the Artsoft programming and tech support) , no matter how smart you believe yourself to be, you'll probably run into problems. So if you post that you wrote your own macro to connect Mach4 to your Apple phone via Bluetooth and then want to use a web browser to change tools, and also put a window up in Mach4 to use a camera or play songs with CarPlay, and your having problems and getting faults when you run your code, and obviously being one smart programmer, it must be Mach4 that's the problem, I shake my head and wonder why you even bother and waste so much of your time. and everyone else's who reads your post.  guess you have nothing better to do.. I do however so bye-bye :o
any semblance of information posted to anything remotely  close to accuracy is merely coincidence. Use at you own discretion.. or play the lottery.. same odds