Rework PauseAtHeight.py - #21327
Conversation
A re-write of the classic Pause script.
|
HellAholic, I changed the name of this one to try to avoid confusion but there would be the question of what to do with the original "PauseAtHeight". |
|
This one I would go with replacement since it's extending the |
|
Crap. |
|
I appears to just have needed a couple of variables renamed so they match from old to new. |
Changed the file name from PauseAtLayerOrHeight to match the existing PauseAtHeight. Additional debugging to insure that this version is backward compatible with the previous version.
|
I've performed some testing on this as I use pausing for filament swaps quite frequently. So far everything seems to work as it should, however I have a couple of implementation queries, which I was wondering if you could help me with for my understanding The first is that I think there is a piece of obsolete code as I don't think the condition could ever be achieved The second query surrounds the switching between Relative/Absolute Extrusion, where I was wondering if there was a reason why the script switches to Relative Extrusion even if Relative Extrusion is already being used then back to Relative Extrusion at the end of the pause. Then only switch to Relative Extrusion & back to Absolute Extrusion at the end if Absolute Extrusion was in use before the pause This would enable this code snipets to be simplified so that the append lines, which use extrusion_mode_numeric would contain an explicit M82 command, which is only appended if Absolute Extrusion was in use before the pause |
|
Removed an uneeded IF statement. changed 2 App.getinstance..." to self.global_stack.
|
Thanks for clearing that up. I only have the one flavour of printer to test this on so never no if there are other printer configurations where the extrusion switching or lack of could cause problems but what you've done is good defensive programming in case something throws a curveball in the future |
|
This one requires some work. The overall tone would be:
I'll do some clean up and post a version here as comment. |
|
Still need to test things out yourself and compare, but this is more of a structural guide. |
|
I'm getting this in a crash report. |
|
It's the setting version, I made a booboo updating it to 3, it should be 2. |
|
In way of an explanation... So I set out to include the unload / reload / purge option to eliminate most of the manual filament handling, and allow for a slightly different configuration between insertions and filament changes. I also wanted to have the ability to utilize a single instance of the PP even for pauses at multiple layers when they were all of the same configuration. So far it seems to run the same with your revisions as it did in my effort. I'll continue to wring it out. PartySausage if you would care to download and test HellaHolic's latest version it would be much appreciated. |
|
GregValiant (@GregValiant) I've tested HellAholic's revised script with a several different theoretical scenarios using By Layer & By Height for All Others & Filament Change pauses with multiple pauses for each and haven't seen any hiccups. 👍👍👍 I've been using my own fork of your script with a couple of extra settings so I merged the new script in with that version, which given the number of changes took some doing. Anyway, the resulting G-Code files seem to contain everything they should |
Changes as made and requested by HellaHolic.
|
Th this afternoon's commit (on 7/5/2026) includes HellaHolic's suggestions and a couple of minor changes by myself. |
There was a problem hiding this comment.
Pull request overview
This PR rewrites PauseAtHeight.py to significantly expand Cura’s classic “Pause at height” post-processing script, adding firmware-specific pause commands, filament unload/reload/purge sequences, multi-pause support, and improved handling for multi-extruder and One-at-a-Time printing.
Changes:
- Adds new pause command options (e.g., Klipper, Raise3D, dwell
G4, custom command) and richer messaging (LCD + print server). - Adds filament-change workflow controls (unload/reload/purge, quick purge, redo-layer flow adjustment) and more parking/clearance controls.
- Adds support logic for One-at-a-Time sequencing and multi-pause lists (comma-delimited layers/heights + messages).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: HellAholic <alireza.doustdar@gmail.com>
Spelling correction. Altered 2 variables.
|
HellAholic |
| # Reset extruder value to pre pause value | ||
| self.pause_lines_list.append(f"G92 E{current_e} ;Reset extruder") |
There was a problem hiding this comment.
GregValiant (@GregValiant)
technically valid but is a very low-impact edge case. Whether it's worth fixing is a judgment call — the fix is a one-liner, but the scenario it covers is nearly hypothetical.
changed "value" to "default_value" Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
I'm sorry I got lost on this one. I had a fiasco involving my water well and I've been busy making the repair. PITA. The original pressure tank lasted 32 years and that was considered the norm. Now it's 3-5 years and they cost 10 times more than they did. Junk. |
|
No rush, just went through the comments co-pilot made to close the ones out of context. Nothing is being built to last anymore. Best of luck on the repairs. Hope both you and your wallet survive the fiasco. |
|
I haven't seen any comments here about the core of the re-design which was to allow a single instance to control multiple pauses, and to add more pause commands, and split off "Insertions" which don't require filament changes. I also like the unload and reload/purge sequence as that was always manual and could be difficult on some machines. I'll keep my hands out of it and let you work. I have t sit here and provide consolation for my wallet. It's pissed. |
|
Did some clean up and separated the big block of |
|
I'm playing with it. So far I haven't been able to break it. |
|
It works for me. |
|
Same here no hiccups so far 👍 |
Erwan MATHIEU (wawanbreton)
left a comment
There was a problem hiding this comment.
Looks good to me ! I do have some remarks/questions, but the global quality is good, and from what I understand it already went through a lot of testing, so feel free to reject the suggestions.
| if is_retracted is None: | ||
| is_retracted = False | ||
| break | ||
| return current_e, is_retracted |
There was a problem hiding this comment.
Is this function working properly with relative extrusion ? Shouldn't it always return 0 in this case ?
| is_retracted = True | ||
| elif current_e is not None and is_retracted is None: | ||
| is_retracted = False | ||
| current_e = new_e |
There was a problem hiding this comment.
Isn't that the same as getPreviousE ?
| if current_z + move_z > self._machine_height: | ||
| move_z = 0 |
There was a problem hiding this comment.
| if current_z + move_z > self._machine_height: | |
| move_z = 0 | |
| move_z = min(move_z, self._machine_height - current_z) |
There are 2 other occurrences below, if you decide to apply it. They could also be moved out the if by the way, so that you would have it only once.
|
Also, can someone explain the "redo layer" principle ? I like the idea of priming the nozzle, but if you replay the entire layer, that is definitely going to over-extrude and make it ugly 🤔 |
|
I made some tweaks but I am also not sure if it's functioning as expected after the changes 😝 So here is the changed version with:
The idea for keeping the obsolete settings was to prevent any breaking for old 3mf files, but they can be filtered out/removed if needed or if their removal doesn't cause a problem. They are disabled so they should not affect the script itself. For the redo layer poking GregValiant (@GregValiant) |
|
The "Redo layer" function is vestigial. I have no idea what scenario would be required for it to be necessary. A full debugging with all options combinations is going to take a while. I'll ignore "Redo" for now as it is an edge use case anyway. It was working fine in previous testing. I have never had occasion to use it in an actual project. |
|
The "E Reset" is now broken for the Redo Layer. The "current_e is incorrect. I'm looking. |
|
Oke, then we can keep the current implementation that is tested and clean things up in a separate later PR. |
Simplify the check and move out of condition to calculate once and use where needed.
|
Removed the redo layer and obsolete settings. |
A re-write of the classic Pause script.
Description
Changes and additions:
Added more 'Pause Command' options for alternate firmware flavors.
Added 'Unload' option (prior to pause) and 'Reload' and 'Purge' options (after the pause).
Added 'Reason for Pause' options.
a. If 'Reason_for_pause' == 'Filament Change' then Unload, Reload, and Purge become available.
b. If 'Reason for Pause' == 'All Others' then the filament change options are hidden as they are not required for insertions or other pause events.
Added 'Multiple Pause Layers' option.
a. This works well when all pauses will have the same settings. Delimit the layer numbers with commas.- If pauses require different settings then add another instance of the script.
b. Multiple messages can be added (also delimited by commas). Each message will be assigned to the equivalent pause layer.
c. Example: For pause layers 15,23,48 the messages could be: White,Red,Blue
Added support for "Firmware Retraction"
Added support for 'One at a Time' print sequence.
a. Pauses can be at different layers in different parts.
b. All pause layers must be listed (use the Cura Preview layer numbers).
c. A pause at 'Layer:5' will only result in a pause at the first layer:5 encountered whereas pauses at '15,23,67' might be in different models.
d. Models can be skipped, or have pauses at different layers than other models, and some models could be different colors or a different material.
Added 'Flow Rate' option for 'Redo Layer'.
a. (Note that "Redo Layer" is disabled when in One-at-a-Time mode.)
Multi-extruder printers now use the Cura settings of the tool that is active when the pause occurs (retraction distance, retract and prime speeds, etc.)
The 'Stepper Timeout' has been de-confused (hopefully).
Obsolete:
The "Retraction option" is removed. Retractions are now handled in the script.
This fixes... OR This improves... -->
Type of change
How Has This Been Tested?
I have been using it for about 2 years now.
Test Configuration:
Checklist:
NOTE: This version has some overlap with the current "PauseAtHeight". That one could be made obsolete as we did with 'DisplayInfoOnLCD'. The original remains but it just shows a message informing the user that they should use the new one.