Mass editing G-code
-
@PeterJones Hi, I really really appreciate your effort. I’m gonna try them out now (if I can find out how). I was last here last week because I was away for the weekend and was busy with school after.
-
Okay, so I managed to install PythonScript. In theory I created the script (made the file, copy pasted your script and saved as you said (18297-gcode-layer-numbering.py))
I created a new file wich contains the directions for the folder I have my gcode files in, saved. But when I start the script, nothing happens. Literally. I click on the 18297-gcode-layer-numbering script and nothing.
I would show some effort, but I really don’t know how this works. I follow your instructions, but for example I have no idea what the script contains.Thank you very much for this, i don’t know what’s wrong.
-
First let’s check if the plugin has been correctly installed.
Can you open the console?
Plugins->PythonScript->ShowConsole
If so, put the following into the run box in the console
notepad.getVersion()
and press enter or click Run
What do you see? -
Thank you very much for this, i don’t know what’s wrong.
Welcome back.
Thanks for taking the effort to decode the script and install PythonScript; it shows you’re not just trying to get us to do your work for you.
First, start with @ekopalypse’s instructions, and tell us what you see.
After that, open your
18297-gcode-layer-numbering.py
: if you go to Plugins > Python Script > Scripts, you can Ctrl+Click on18297-gcode-layer-numbering.py
to open it for editing.You’ll notice there are a few lines that start with
#console.
– remove the#
comment marker. Save.Open your map file like I showed, making sure you are using the paths to your actual files, and whatever ID you want for each file. It needs to be in the active/top editor window.
Then use Plugins > Python Script > Scripts, and normal-click on
18297-gcode-layer-numbering.py
to run the script. If the PythonScript console wasn’t showing before, it should now.
And you should seefilename = '...', xid = '...'
for each file as it’s processing.If you see any red text in the PythonScript console window, you’ll have copy the whole console window, and paste the contents (especially the error) into your reply in the forum. Once you paste, hightlight that section you pasted and click the
</>
to mark that section as code, so we get the actual characters you see. -
-
Sorry, I forgot that since you were decoding it, the forum wouldn’t gobble the indents.
In the script, Ctrl+A to select all, then Shift+TAB twice to un-indent twice. Save. Then go back to your map file and run the script again.
-
This post is deleted! -
@PeterJones said in Mass editing G-code:
then go back to your map file
You’ll also want to make sure your map file isn’t indented. Again, select all and Shift+TAB until it’s no longer indented.
-
Thank thanks thanks guys. I’ll test it on my printer soon, it is printing atm.
I really appreciate it! -
@PeterJones well I have good and bad news. The good is, your script works flawless, but turns out the gcode needs that line. Can you help me edit the script to insert the
M117 LayerX/sumX
line AFTER the
;Layer:X
line?
-
Good news and bad news:
edit the script
Change the
lambda m:...
line to:lambda m: str(m.group(0)) + "\r\nM117 Layer:" + str(m.group(1)) + '/' + xid
The
m.group(0)
contains the whole original match. The\r\n
add a windows CRLF newline between the original match and the new text. The rest is the same as before. -
Now it works like a charm. Thank you again!