Rarely do I get to contribute much however I think I have figured out how to do something that hasn't been posted yet, so I wanted to share.
Specifically how to add a pause at a specific layer while using a Raise3D [R3D] printer. This may also be useful to other printers if you have similar printer behavior as the R3D, but you'll have to modify any specific "pause" M-Code commands. If you have this printer you know that there is no firmware support for pausing at a specific height and raise3D recommends you use the feature in ideamaker to pause at a specific height. But, since S3D is awesome I wanted to figure out how to do it...
This script also address another issue not currently addressed by raise3D which is: their pause routine will keep the bed at the same height. Now if you pause at a moderate "Z" height, loading a filament isn't a problem, however if you want to have a pause at a low height (say a few millimeters) than getting filament to load may be an issue because the purge hits the bed immediately due to the close proximity of the nozzle.
Enter "Additional terminal commands for post processing" stage right... Before getting into the actual post processing command, take a look at the desired G-Code we want the machine to run:
Desired G Code: (I am using layer 5 as an example, but it can be any layer you choose)
G91; Relative Positioning
G1 Z50 F1800; Move Bed down 50mm
G90; Absolute positioning
G1 X10 Y10 F5400
M2000; Enter Pause routine for R3D
;Layer 5
G91; Relative Positioning
G1 Z-50 F1800; Move Bed up 50mm
G90; Absolute positioning
So how does this break down: it basically says: Just before layer 5 I want you to move the bed down 50mm and then go to a staging area at location X=10, Y=10 and enter the pause routine in the R3D printer. When the printer is unpaused, the bed will come back the 50mm it dropped and resume the rest of the printing. On the face of it, pretty easy to understand however there are a few hidden idiosyncrasies that you have to account for to make this work...
To get this into the post processor, I've used the replace command to search for a specific layer and to add the G-Code I described above. Before getting into the code you must consider that S3D (in my version 3.1.0) puts a comment for each new layer that looks like this:
; Layer 5, Z=1.02
So when we search in our replace code, we want to make sure that we include the comma [,] in the search. This prevents us from entering the wrong code on a line that starts with "layer 5" for example, we don't want this code on layer 50... There is a consequence to using this technique which is the characters in that line, after the comma, are left behind. If you aren't careful to account for the remaining "z=1.02" this could cause you problems. We are able to fix this by adding a carriage return and comment character [semicolon in this case - ; ] at the end of our replace script.
So when you do all of that, you end up with the following:
{REPLACE "; layer 5," "G91; Relative Positioning\nG1 Z50 F1800; Move Bed down 50mm\nG90; Absolute positioning\nG1 X10 Y10 F5400\nM2000; Enter Pause routine for R3D\n;Layer 5\nG91; Relative Positioning\nG1 Z-50 F1800; Move Bed up 50mm\nG90; Absolute positioning\n; "}
{REPLACE ", Z" "\n; Z"}
A few of there comments to consider:
1. The second "replace" function is not needed, but it searches the rest of the g-code and makes a new line for all of the "Z=[heigh]" comments to make them consistent with the g-code that you've just replaced.
2. The R3D printer does not resume at the same speed in which you paused it from which is why there are speed commands listed in the g-code that is substituted. You should make sure that the code you use, matches the speeds you want (remember mm/min!!!)
3. You are going to have to modify this code on the latest "released" version of touch control... I know what you're thinking, what a "dick to post code that needs to be modified"... but its true. Specifically, the most current version of the touch control doesnt allow a comment on the same line as a command. so this means you need to do one of two things: delete the comments in the replace feature OR add extra "\n" before and after the comments to make them a separate line with only a comment on it. Some beta versions of their firmware suggest the next versions will allow comments on the same line, so hopefully this wont be necessary for long...
I suggest testing your script while you are home on a simple print, like a 20mm cal-cube to verify that it works at the desired layer height AND that it doesnt add your g-code modifications to a similar layer (like layer 50 in this example...).
Best of luck all, I hope you find this as useful as I did!