Hello Guest it is May 12, 2021, 02:47:51 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - hankb

Pages: 1
1
Solved! (at least for my use case)

I'm kinda embarrassed it took me so long to consider hidden characters, especially since I was grabbing an entire line from the Gcode to create the variable (carriage return at the very least, duh)

The hidden characters were removed by adding  %c%s to the existing string.gsub command, removing control characters and space characters.

Here's the code that is working for me:

Code: [Select]
--Function to automatically load and start next file, grabbed from comment in current file
function M100 ()

local inst = mc.mcGetInstance()
mc.mcCntlCycleStop(inst) -- stops cycle

local NextFileParen = mc.mcCntlGetGcodeLine (inst, 1)
--gets name of next Gcode file MUST BE COMMENTED INTO LINE 1 OF CODE

local NextFile = string.gsub(NextFileParen, "[()%c%s]", "")
--strips parentheses, control characters, and spaces

wx.wxSleep(1) --gives Mach a second to do its thing

mc.mcCntlLoadGcodeFile (inst, NextFile) -- loads up the file

mc.mcCntlCycleStart(inst) --automatically cycle start. comment out to allow manual start instead.

end

and here's what LINE 1 of the Gcode looks like that it is referencing:

(C:\\gcodetest\\TEST2.txt)

Note the double backslash. Alternatively, it also works with single forward slash like such:

(C:/gcodetest/TEST2.txt)


Hopefully this helps someone else out!
hank

2
Thanks for the suggestion!

I read up on it a bit and I like the simplicity of the approach, except that the subroutine folder isn't really a great place for this many files*, and I can't seem to sort out how to call a file in another location. It looks like someone figured out on Mach3 how to call a file with any path by placing a "-" before the path, (found here: https://www.machsupport.com/forum/index.php?topic=15528.0) but that trick doesn't seem to be working for Mach4.

If I *could* call a file from any location, i do really like the simplicity of this approach.

 *Current file organization has nested folders: Project>Panel>Piece. Each project has dozens of panels, and each panel can have a dozen pieces. Piling them all into one folder would be a step backward in terms of navigation/organization.

3
Also note:

I am also looking at an alternative route where I save the path to a register, and use a button to read from the register to load the file. I am able to write to and read from the register, but even loading the Gcode from the button is causing issues.

To test the most basic scenario I attempt to use the following script in a button:

Code: [Select]
local inst = mc.mcGetInstance()
mc.mcCntlLoadGcodeFile(inst, "C:\\gcodetest\\TEST2.txt")

And i receive the following: "error 5: access denied"

Either of these methods would be acceptable, does anyone happen to know a solution?
Thank you,
Hank

4
Hello Mach4 gurus,

I have a machine that runs a long list of sequential files (hundreds of files, with each file running for just a few minutes). In order to streamline the process of running, I would like to accomplish the following:

When Gcode file is finished running, automatically load the next Gcode file.     
(Note: My post-processor is able to insert the path for the next file as a comment in the current file.)


The test Gcode file is "C:\gcodetest\TEST.txt"
The first few lines look like this:

Code: [Select]
(Next File in Queue)
(C:\\gcodetest\\TEST2.txt)

F60.000000
G0 X0.000000 Y0.000000 Z0.200000
M3 (start Spindle)
S60.000000
G0 X0.000000 Y0.000000 Z5.00000
G0 X1.179950 Y4.004260 Z0.200000
M100

Just enough to demonstrate that the file loads and runs the machine, then test M100.

The M100 code looks like this:

Code: [Select]

function M100 ()

local inst = mc.mcGetInstance()

-- Get next file name
local NextFileParen = mc.mcCntlGetGcodeLine (inst, 1) --gets name of next Gcode file
local NextFile = string.gsub(NextFileParen, "[()]", "") --strips parentheses
wx.wxMessageBox("Next file path - "..NextFile) --for troubleshooting

--Close current file
mc.mcCntlCloseGCodeFile (inst)
wx.wxMessageBox("closed - "..CurrentFile) --for troubleshooting

--Load next file **NOT WORKING**
mc.mcCntlLoadGcodeFile (inst, NextFile)
wx.wxMessageBox("opened "..NextFile) --for troubleshooting

end


This macro runs through the end (including the last message box), but does not load the next file.

Does anyone know how I could get this macro running?
Thank you for your insight,
Hank

Pages: 1