Hi Cleavitt,
This may be too much information, but I’m trying to be as thorough as possible.
I’ve done a lot of testing with standard PETG that tends to blob. As of today, no more prints are being ruined!
With this G-code, the retraction was initially 2 mm, and I adjusted it to 0.95 mm to properly refill the nozzle. This helps avoid under- or over-extrusion at the restart after cleaning. To test this, I printed a very small object (30 × 5 × 2 mm), standing on the 30 × 2 side, and triggered cleaning every 20 layers.
The temperature can also be lowered to further optimize results. I found that 245 °C works well.
To change how often cleaning occurs (number of layers), you’ll need to adjust this directly in the G-code where you’ve inserted it.
The original code was written by JK3D and can be found on MakerWorld—thanks to JK3D for this!
Once installed, the code will appear in the G-code list generated by the Bambu Lab slicer, where you can verify that it is present. The steps (1 to 4) guide you in replacing the existing G-code with the version below:
;============= H2S 20250611 =============
; layer num/total_layer_count: {layer_num+1}/[total_layer_count]
;### START: PETG NOZZLE WIPE SEQUENCE ###
; This logic handles nozzle cleaning at critical stages: Layer 2, every 5 layers, and the final layer.
{if (filament_type[initial_no_support_extruder] == “PETG”) && (layer_num > 0)}
; — LOGIC —
; Check if current layer is: Layer 2 OR every 20 th layer OR the very last layer
{if (layer_num == 2) || (layer_num % 20 == 0) || (layer_num == (total_layer_count - 1))}
M117 Nozzle Wipe Sequence (L:{layer_num})
M400 ; Finish all moves
G91 ; Relative positioning
G1 Z0.4 F1200 ; Z-Hop
M83 ; Relative extrusion
G1 E-2.0 F1800 ; Retract to prevent oozing
G90 ; Absolute positioning
G150.3 ; Move to trash bin area
G150.1 F8000 ; Wipe sequence 1
G150.1 F8000 ; Wipe sequence 2
G150.1 F8000 ; Wipe sequence 3
G1 E0.95 F1800 ; Prime nozzle was 2.0 to prevent oozing
G91 ; Relative positioning
G1 Z-0.4 F1200 ; Return Z to original height
G90 ; Absolute positioning
{endif}
{endif}
;### END: PETG NOZZLE WIPE SEQUENCE ###
; update layer progress
M73 L{layer_num+1}
M991 S0 P{layer_num} ;notify layer change
The modified G-code should now be visible after slicing:
NOTICE FOR BAMBU LAB DEVELOPERS:
This tool is extremely valuable because it prevents blobs, saves prints, and reduces frustration.
It would be greatly appreciated if you could implement a parameter based on time (e.g., every X minutes) or filament usage (e.g., every X grams consumed) to trigger each wipe sequence.
Kind regards,
And as always, please be careful when making changes—you do so at your own responsibility.
Ronny