Skip to content

Rework PauseAtHeight.py#21327

Open
GregValiant (GregValiant) wants to merge 3 commits into
Ultimaker:mainfrom
GregValiant:Create_PauseAtLayerOrHeight
Open

Rework PauseAtHeight.py#21327
GregValiant (GregValiant) wants to merge 3 commits into
Ultimaker:mainfrom
GregValiant:Create_PauseAtLayerOrHeight

Conversation

@GregValiant
Copy link
Copy Markdown
Collaborator

@GregValiant GregValiant (GregValiant) commented Jan 22, 2026

A re-write of the classic Pause script.

Description

Changes and additions:

  1. Added more 'Pause Command' options for alternate firmware flavors.

  2. Added 'Unload' option (prior to pause) and 'Reload' and 'Purge' options (after the pause).

  3. 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.

  4. 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

  5. Added support for "Firmware Retraction"

  6. 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.

  7. Added 'Flow Rate' option for 'Redo Layer'.
    a. (Note that "Redo Layer" is disabled when in One-at-a-Time mode.)

  8. 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.)

  9. The 'Stepper Timeout' has been de-confused (hopefully).

  10. Obsolete:
    The "Retraction option" is removed. Retractions are now handled in the script.

This fixes... OR This improves... -->

Type of change

  • [ X] New feature (non-breaking change which adds functionality)

How Has This Been Tested?

I have been using it for about 2 years now.

Test Configuration:

  • Operating System:
  • Windows 10 Pro
  • Cura versions 4.13.1 through 5.12.1

Checklist:

  • [ X] My code follows the style guidelines of this project as described in UltiMaker Meta and Cura QML best practices
  • [ X] I have read the Contribution guide
  • [ X] I have commented my code, particularly in hard-to-understand areas
  • [ X] I have uploaded any files required to test this change

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.

A re-write of the classic Pause script.
@github-actions github-actions Bot added the PR: Community Contribution 👑 Community Contribution PR's label Jan 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Test Results

24 518 tests  ±0   24 516 ✅ ±0   50s ⏱️ -1s
     1 suites ±0        2 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit dfe9c68. ± Comparison against base commit 4f28ea8.

@GregValiant
Copy link
Copy Markdown
Collaborator Author

HellAholic,
Do you think there is a chance of this being added(?) or as a replacement.

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".

@HellAholic
Copy link
Copy Markdown
Contributor

This one I would go with replacement since it's extending the Pause At... in my opinion. As what to do with regards to the behavior to support previous workflows, we can have the default values set in such a way that the behavior would be the same as the previous script.

@GregValiant
Copy link
Copy Markdown
Collaborator Author

Crap.
I'll go over it and see what needs to be done. Things like "Disarm Timeout" was in seconds but I changed that to minutes. There might need to be some "conversions" needed.

@GregValiant
Copy link
Copy Markdown
Collaborator Author

I appears to just have needed a couple of variables renamed so they match from old to new.
I have to wring it out some more, but I don't anticipate a lot of work there.

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.
@GregValiant GregValiant (GregValiant) changed the title Create PauseAtLayerOrHeight.py Rework PauseAtHeight.py May 9, 2026
@PartySausage
Copy link
Copy Markdown

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

                elif self.redo_layer and self.reason_for_pause == "reason_other":
                    self.pause_lines_list.append(f"M{extrusion_mode_numeric} ; Switch back to {extrusion_mode_string} E values")`

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.
I was thinking that an easier solution would be to do the check whether Relative Extrusion was being used here`

           # Don't change the extrusion mode if pause method is UM 'griffin'
            if pause_method != "griffin":
                self.pause_lines_list.append("M83 ; Relative extrusion")

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

                extrusion_mode_string = "absolute"
                extrusion_mode_numeric = 82

                relative_extrusion = Application.getInstance().getGlobalContainerStack().getProperty("relative_extrusion", "value")
                if relative_extrusion:
                    extrusion_mode_string = "relative"
                    extrusion_mode_numeric = 83

                if not self.redo_layer:
                    self.pause_lines_list.append(f"M{extrusion_mode_numeric} ; Switch back to {extrusion_mode_string} E values")

@GregValiant
Copy link
Copy Markdown
Collaborator Author

  1. When I started on the revision my incliniation was to simply remove "redo layer". Later I saw a way to keep it in when "All Others" was true. I went back and made the change. As a result of that change, the "elif" statement can never be true ("redo_layer" is not available when "reason_other" is true). I will remove that "If" statement.

  2. That also looks like vestigial code BUT it insures that the extrusion mode is set correctly to "relative" when the print resumes so I'm inclined to leave it. There may have been a condition I came across during debugging (with Firmware Retraction enabled?) where it was needed.

Removed an uneeded IF statement.
changed 2 App.getinstance..." to self.global_stack.
@PartySausage
Copy link
Copy Markdown

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Community Contribution 👑 Community Contribution PR's

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants