Skip to content

Create RetractContinue.py #20675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

GregValiant
Copy link
Collaborator

@GregValiant GregValiant commented Jun 10, 2025

Complete Rewrite of Retract Continue.
I'll leave this as a draft. @HellAholic , this is another one I'm not really sure where it should go. The Slic3R clones have this built-in.

Description

This version works with Z-hops and Relative Extrusion.
For multi-hot end printers the retraction settings are always from T0.
This version does not retract beyond the "Retraction Distance" in Cura.
The user enters the range of layers and the "Initial Retraction Percentage". The remainder of the Retraction Distance is spread across the following travel moves as "mm of filament percentage" per "mm of travel":

G1 F3000 E-7.0                          ; Retract 70%
;WIPE_START
G1 F600 Z13.3                           ; Hop Up
G1 F10500 X98.969 Y109.097 E-0.03368
G1 X98.982 Y107.617 E-0.04474
G1 X64.348 Y107.617 E-1.04696
G1 X64.337 Y132.536 E-0.75328
G1 X64.494 Y132.989 E-0.01448
G1 X64.716 Y133.341 E-0.01258
G1 X65.271 Y133.783 E-0.02143
G1 X65.801 Y133.905 E-0.01644
G1 X98 Y133.935 E-0.97335
G1 X98 Y131.187 E-0.08307
;WIPE_END
G1 F600 Z12.8                           ; Hop Down
G1 F3000 E10

That may look familiar to some people.

This fixes... OR This improves... -->
Problems with the original exceeding the retraction distance.

Type of change

  • [ X] Bug fix (non-breaking change which fixes an issue)
  • [ X] New feature (non-breaking change which adds functionality)

Test Configuration:

  • Operating System: Windows 10 Pro
  • Cura 5.10.0

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

Complete Rewrite of Retract Continue
@github-actions github-actions bot added the PR: Community Contribution 👑 Community Contribution PR's label Jun 10, 2025
@GregValiant GregValiant marked this pull request as draft June 10, 2025 14:34
@GregValiant GregValiant requested a review from HellAholic June 10, 2025 14:40
@HellAholic
Copy link
Contributor

HellAholic commented Jun 10, 2025

There is a ticket that I'm currently taking a look at for retract and priming during a travel move
Does that sound similar to this one?
The only missing component is the start / end layer limit as far as I can see, but I just skimmed through this one

#20240

Copy link
Contributor

Test Results

23 775 tests  ±0   23 773 ✅ ±0   47s ⏱️ -1s
     1 suites ±0        2 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit ea9d9fb. ± Comparison against base commit 6ac6228.

@GregValiant
Copy link
Collaborator Author

GregValiant commented Jun 10, 2025

That looks like it. Glad I didn't spend too much time on this.
The sequence for this one is:

  1. The user inputs the Start and End layers and the "Initial Retraction" percentage.
  2. The Retraction Distance is pulled from Cura.

When the script runs:

  1. All retractions are adjusted so the "Initial Retraction" is the user input percentage.
  2. The remainder of the retraction is spread out across the following travel moves and are proportional to the length of each individual travel move.

I see Erwan was concerned about "speed" but I don't see an issue. It's a retraction so if it happens at travel speed it doesn't matter. Typically the retraction distance will be small (notably small on DD extruders) and the M203 Maximum E Speed will act as a governor when required.

Here are two examples. I had set the Retraction Distance to 10 to make the math easier to see.
The retraction line was altered to 70% and the remaining 30% occurs during travel. (Those are the Slic3R defaults.)

G1 F3000 E-7.0                          ; Retract 70%
;WIPE_START
G1 F10500 X98.969 Y109.097 E-0.03368
G1 X98.982 Y107.617 E-0.04474
G1 X64.348 Y107.617 E-1.04696
G1 X64.337 Y132.536 E-0.75328
G1 X64.494 Y132.989 E-0.01448
G1 X64.716 Y133.341 E-0.01258
G1 X65.271 Y133.783 E-0.02143
G1 X65.801 Y133.905 E-0.01644
G1 X98 Y133.935 E-0.97335
G1 X98 Y131.187 E-0.08307
;WIPE_END
G1 F3000 E10

Al the wipe lines add up to 3mm.

Sometimes there will be a single travel move and it might be short.

G1 F4500 X94 Y132.988 E0.84148
G1 F3000 E-7.0                          ; Retract 70%
;WIPE_START
G1 F10500 X96 Y132.988 E-3.0
;WIPE_END
G1 F3000 E10

In that case the "Max E Speed" might kick in and govern the travel speed, but it won't over-stress anything. In that single move above - there is a 2mm travel move with a 3mm retraction.

This example is from Prusa/Orca. They call out the Travel Speed prior to the wipe moves. Cura does the same although on a single line.

G1 E-4.9 F3600
;WIPE_START
G1 F7200
G1 X58.704 Y53.84 E-.0285
G1 X60.005 Y52.43 E-.91129
G1 X61.968 Y50.976 E-1.16021
;WIPE_END
G1 X93.369 Y138.787 F9000
G1 E7 F2400

I think it belongs inside Cura. I don't think it needs to be very complicated. I spent more time worrying about interferences with my other scripts than I did on the main body of this script.

One of the problems with the original "Retract Continue" script was that the user input for "Extra Retraction Ratio" was a weird unit and it was very easy for a user to end up with a 20mm retraction. Not good.

@GregValiant
Copy link
Collaborator Author

@HellAholic Can this be closed?

@HellAholic
Copy link
Contributor

I'm not sure if the original script is gonna be deprecated as we do have the setting in experimental. There are still functionalities that the script offers and we don't have them implemented (layer range for example).
If the code is good and it resolves a bug / issue, we can keep it open and take a look, work has already been done by you so let's keep it open for now.

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.

2 participants