RomeFallsAgain
Posts: 128
Joined: Wed Nov 18, 2015 6:56 pm

Inserting custom GCode - Process startup scripts

I have a design in which I have created several different "Processes" that change the temperature, speed, infill and supports at various points in my build.

I want to add M72 commands in my GCode that will alert me when the printer is about to start on the next process so I can watch for any problems.

I don't see how to do this.

Within each process, there is a SCRIPTS tab. And under the Scripts tab, several sub script edit boxes. One being the Startup script. What I find strange is that each process has the same startup script and it is the one used only once, at the beginning of the build. Seems to me the startup tab under ALL but the first process should contain no startup script. And that is where you could add any custom "startup script" for THAT particular process. Only the very first process needs the global startup script for the starting of the entire build.

So for example, for Process 2, I should be able to delete whatever text is currently in the Startup Script box and enter whatever code I want to occur when THAT particular process begins. Maybe it does work that way? I haven't tried it.

My printer only reads X3G files and I assume those are compiled from the GCode files when I click "Save Toolpath To Disk" (or begin the build via USB cable)

How would I add the custom M72 P2 commands within the GCode BEFORE I compile to generate the X3g file?

Thanks
CompoundCarl
Posts: 2005
Joined: Wed Aug 05, 2015 7:23 am

Re: Inserting custom GCode - Process startup scripts

Nope, you definitely wouldn't want it to work like that. Most standard starting scripts include things like homing, purging, preheat temps, and all kinds of stuff. You don't want those running every time you switch to a new process. So you are correct, I believe the starting script is only run at the very beginning of the print.

If you want to display a message at different points in the build, here's what I would do. First, just setup all your processes and then click "prepare to print" to look at the preview. Set the preview to "By Layer" mode, and then scroll through the build. Find the layer where you want a notification. Let's say it's layer 20 (perhaps that is right when your second process starts). Exit the preview, and go to the Scripts tab for your first process. Add the following line into the "commands for post-processing" section.
{REPLACE "; layer 20\n" "; layer 20\nM72\n"}

Now your printer will play a tune right before layer 20 starts :D
RomeFallsAgain
Posts: 128
Joined: Wed Nov 18, 2015 6:56 pm

Re: Inserting custom GCode - Process startup scripts

CompoundCarl wrote:Nope, you definitely wouldn't want it to work like that. Most standard starting scripts include things like homing, purging, preheat temps, and all kinds of stuff. You don't want those running every time you switch to a new process. So you are correct, I believe the starting script is only run at the very beginning of the print.

If you want to display a message at different points in the build, here's what I would do. First, just setup all your processes and then click "prepare to print" to look at the preview. Set the preview to "By Layer" mode, and then scroll through the build. Find the layer where you want a notification. Let's say it's layer 20 (perhaps that is right when your second process starts). Exit the preview, and go to the Scripts tab for your first process. Add the following line into the "commands for post-processing" section.
{REPLACE "; layer 20\n" "; layer 20\nM72\n"}

Now your printer will play a tune right before layer 20 starts :D
Thanks Carl!
So "Post Processing" is where it's done.

Here is what I could find on Post Processing...
I intend to learn it :-)

Below are the post-processing tools that also work in the post-processing box:

{REPLACE "E" "A"} - search and replace for the text within quotes, in this example every "E" character would be replaced with an "A" character
{PREPEND "G92 E0\n"} - prepends the specified text at the very beginning of the gcode file, note that the \n is converted into a true newline character, not two separate "\" and "n" characters
{APPEND "G28 X0 Y0\n"} - appends the specified text to the very end of the gcode file
{DELETE "M82\n"} - deletes every occurrence of the specified text from the gcode file, note that it will not automatically delete a line if it is suddenly empty after the deletion, so that is why you might want to include the \n at the end (so that the empty line is also removed)
{STRIP ";"} - completely deletes every line in the gcode file that begins with the specified text
{TOOL0REPLACE "E" "A"} and {TOOL1REPLACE "E" "B"} - these special TOOL#REPLACE commands will do a search and replace, very similar to the {REPLACE} command, however, the replace only occurs if the specified tool is active. For example, when using TOOL1REPLACE, the replacement will only occur if tool 1 was currently active at that line of the gcode file

Happy Holidays!

Return to “General Discussion and Tips”