X2D Manual Aux fan control in cooling mode and disable autocooling for PETG+PLA

M106 P3 S204 ; turn on chamber fan for cooling Back 80%
M106 P2 S128 ; turn on auxiliary fan Left 50%
M106 P10 S153 ; turn on chamber fan Right 60%

probably a typo

I know that – I can read, and I already mentioned in my last post that the code is different.

Apart from the VentoBox option on the P2S and the second auxiliary fan (P10) on the X2D, the code is “almost” identical.

If you want to mimic the PETG printing behavior of the P2S (and it works well), you would have to deactivate the left auxiliary fan.

That means deleting/commenting out all M106 P10 entries in the machine start gcode and layer_change gcode, and in the PETG filament profile – under cooling – setting the 40% for the auxiliary fan (it’s 0% on the P2S!!!) to zero percent.

I suspect that the latter will already improve PETG printing.

It would be necessary to investigate further to what extent the exhaust chamber autocooling (M142) affects the deactivated left AUX fan.

I also noticed the very short set airduct mode in the machine start gcode for the X2D.

X2D start gcode / set airduct mode:

;==== set airduct mode ==== 
{if (overall_chamber_temperature >= 40)}
M145 P1 ; set airduct mode to heating mode for heating
M106 P2 S0 ; turn off auxiliary fan
M106 P10 S255 ; turn on filter fan
{else}
M145 P0 ; set airduct mode to cooling mode for cooling
M106 P2 S255 ; turn on auxiliary fan for cooling
M106 P10 S255 ; turn on auxiliary fan for cooling
M106 P3 S127 ; turn on chamber fan for cooling
;M140 S0 ; stop heatbed from heating
M1002 gcode_claim_action : 29
M191 S0 ; wait for chamber temp
M106 P2 S102 ; turn on auxiliary fan
M106 P10 S102 ; turn on chamber fan
M142 P6 R30 S40 U0.6 V0.8 ; set PLA/TPU/PETG exhaust chamber autocooling
{endif}
;==== set airduct mode ====

… and from P2S:

;==== set airduct mode ==== 
;==== if Chamber Cooling is necessary ====
{if (overall_chamber_temperature >= 40)}
M145 P1 ; set airduct mode to heating mode for heating
M106 P2 S255 ; turn on filter fan
M622.1 S0
M1002 judge_flag ventobox_replace_aux1_fan_flag
M622 J0
M106 P10 S0 ; turn off left aux fan
M623
{else}
{if (min_vitrification_temperature <= 50)}
M145 P0 ; set airduct mode to cooling mode for cooling
M106 P2 S255 ; turn on auxiliary fan for cooling
M106 P3 S127 ; turn on chamber fan for cooling
M1002 gcode_claim_action : 29
M191 S0 ; wait for chamber temp
M106 P2 S102 ; turn on chamber cooling fan
M622.1 S0
M1002 judge_flag ventobox_replace_aux1_fan_flag
M622 J0
M106 P10 S0 ; turn off left aux fan
M623
M142 P6 R30 S40 U0.3 V0.8 ; set PETG exhaust chamber autocooling
{else}
M145 P1 ; set airduct mode to heating mode for heating
M106 P2 S127 ; turn on 50% filter fan
M142 P6 R30 S40 U0.3 V0.8 ; set PLA/TPU exhaust chamber autocooling
{endif}
{endif}
;==== set airduct mode ====

The min_vitrification_temperature <= 50 comparison is not available for the X2D. I’m not entirely sure if this is only for the VentoBox option on the P2S.

However, the M142 values ​​differ between the two printers:
U0.3 V0.8 (P2S) vs. U0.6 V0.8 (X2D)
The X2D regulates more strongly/higher during autocooling.

Perhaps this offers a solution to the problem?

1 Like

Thank you for this profile. It is getting me by at the moment, but we still need Bambu to give us other options besides strong automatic cooling.

2 Likes

I think I understand why they did what they did. Even judging by the comments in this thread, many people seem to think there is one universal setting that will work for all models, regardless of the shape or size of the part, just because it worked for them on a single model on the P2S.

In my opinion, Bambu is trying to make the process as painless as possible, while still leaving manual options available for users who want more control. Figuring out the “right” fan settings for your specific needs is much harder than simply slicing with an already prepared profile. So if someone already feels that’s too much of a hassle, they probably shouldn’t be adjusting those settings in the first place.

Bambu could block what we are doing here in a second, but they clearly understand that advanced users have different needs, and they do accommodate that. Personally, I don’t even think they need a dedicated “manual” option in the menu. If they ever added that, I think it would be a mistake and would only create more support tickets than necessary.

People complain that Bambu doesn’t allow tinkering, but when they do, people complain that they’re not making it easy enough :slight_smile:

1 Like

In this case they aren’t though, are they? Why not add a menu option to control fan speed? Seems like something obvious to have. As for support tickets, BL can just say “well, you have manual fan speed set, change it to auto then get back to us if you still have issues”.

In your original post it seems you can already adjust the fan speed via the menu but it resets back to default. Is that right? That almost sounds like a bug, rather than an intended feature.

Hey, but what do I know, I still don’t own one LOL.

1 Like

Just my opinion: I think the majority of users are beginners, and they would start the print job, lower the fan to 30%, forget about the 10-hour print, leave, and then 8 hours later — if there isn’t a massive fire — a clog or blob of death would appear. Then everyone would start screaming: “Why doesn’t this printer know it needs to readjust the fan speed?”

So they made an auto profile that works for 95% of prints.

We are making a manual profile for long PETG parts where warping might — but not necessarily will — appear. I still stand by my theory: Bambu Lab protects users from their inexperience, and rightly so.

I don’t believe a beginner will be looking at a 10-hour print and monitoring temperatures just to manually readjust fan speeds later… ain’t happening.

I believe they should add the menu option to disable auto cooling entirely, but bury it in the slicers advance and develop modes so that it’s only accessible to the advanced users. Well, it’ll technically be available to anyone who enables develop and advanced modes, but a newbie isn’t going to find these settings until they need them.

Did we ever figure out why your gcode is different and has the extra lines in it compared to the default?

Just wanted to update. I spoke with support about this and they are actively seeking solutions to allow users to control the aux fans. I suggested a toggle to disable auto cooling in the slicer but to hide it in develop mode like some of the other advanced user settings are. They seemed to like this idea. Their main worry is print reliability for people who don’t know what they’re doing. They don’t want rookies turning them on manual mode and then it causing issues such as heat creep because the chamber won’t be cooling. This worry seems justified to me. Hopefully they give us advanced users a toggle soon. I’m willing to bet all of us advanced users already have develop mode in the slicer turned on.

1 Like

I just spent almost the whole day debugging why my PETG prints were lifting up. Fresh X2D owner, and spoiled by P2S. The last thing I expected was the aux fan, as I had prepared the profiles accordingly. It’s loud in my workshop, so I didn’t notice it turning on. What a surprise it turned out to be—I was tweaking everything, and aux fan speed too.

The issue is complicated. In my experience, this option needs to be a bit smarter than a simple on/off, as everything depends on the geometry of the print. I managed to complete mine by lifting the top glass, and manually turning off the fan for PETG and turning it on for PLA before the g-code actually changed the settings. If I left the fan off, the aux extruder struggled to feed the filament as it wasn’t adhering to the PETG surface.

Granted, I’m not using Bambu filaments, so perhaps it’s a completely different ballpark, but still—for a printer designed with an Bowden as aux so basically a support mainly, it’s a bit of a bummer how it handles it. At least, that’s how I feel right now after wasting a lot of time and filament.

Still, the print finally came out great. I’m just hoping this will be sorted out in the slicer interface, as I’m not looking forward to editing the g-code for every future print. :slight_smile:

I had the same issue when printing supports. The fans kept spinning up for PLA making the PETG very brittle.
Tried changing gcode, but nothing really worked.

Then i realized: why are the aux fans not spinning up for PETG, but do spin up for PLA?
I believe it’s the “Softening temperature” setting in Filament settings (first tab)

When set ridiculously high, say 100 degrees, the aux fans do not spin up.
(Which in its turn caused a nasty heatcreep blob on my X2D)

1 Like

Hi.

This is an absolute pain in the ■■■ when printing PETG with PLA support interfaces on the X2D.

The printer automatically ramps the auxiliary cooling fan to 100%, and within minutes the PETG starts warping, lifting from the build plate, and ruining the print.

What exactly were QA and QC looking at when validating these profiles and default cooling behaviors? One of the main selling points of the X2D is dual-material printing (with PLA/PETG in my case), yet the machine actively sabotages that workflow out of the box.

For a machine marketed as a next-generation dual-nozzle platform, this is honestly a pretty bad look. Users should not have to spend hours hunting down hidden cooling overrides just to make a flagship feature work reliably.

What a shame. :confused:

The hardware deserves better software defaults.

@Sebo3D1 thx!
Also if i have such behavior where Aux fan must rump to 70% - it does’n work, it’s will work at 40% and don’t ramp up?

The code I posted allows for full manual fan control, exactly as originally requested by the user. There are no automatic “ramp-up” features or other advanced control logic—just straightforward manual control with safe initial settings.

The code can easily be modified for specific filament type or use cases. For example, you could increase or decrease the left or right fan after a certain layer, adjust fan speeds based on print stages, or implement virtually any custom behavior. With custom code, almost anything is possible.

The challenge is that there is no single “best” fan control strategy that works for every scenario. Different materials, models, layer times, ambient conditions, and print geometries all require different approaches, making a universal solution impossible to implement.

In theory, some kind of AI-driven thermodynamic model could automatically adjust fan speeds based on part geometry, material properties, and real-time printing conditions (temp). However, I’m not sure many people would be willing to pay for that level of complexity just to print slinky dragons.

Therefore, in my opinion, it is better to control the fan from the filament settings, so for a certain geometry, etc., it is faster and easier to fix there than to correct the g-code of the printer, especially if you do not know where and how.

Can you tell what i need to uncomment for Liner ramp up settings start work?

The do it from filament settings…in my opinion thats not the way, but feel free to try it and report back

Hi,
i played a lot with the automated fan control and this is what i came up with:
M142 P6 controls the exhaus fan
M142 P1 controls both aux fans
R: lower regulation temperature
S: Upper regulation temperature
U: minumum fan speed for regulation
V: maximum fan speed for regulation
O: Threshold for temperature alarm (Only working for M142 P1)

with those controls in mind its easy to generate a own post processing. I fully switch off fans during the first X layers defined in the filament settings. For low fan speed of M142 P1 i use the aux fan setting of the filament setup, and for max fan speed i add 20% to this value. The alarm value is choosen by the lowest softening temperature in the project, just to be on the safe side when printing PLA. I hope that information is helpful for some of you.

2 Likes

This is my setup for more control:
start code:
…
;==== set airduct mode ====
{if (overall_chamber_temperature >= 40)}
M145 P1 ; set airduct mode to heating mode for heating
M106 P2 S0 ; turn off auxiliary fan
M106 P10 S255 ; turn on filter fan
{else}
M145 P0 ; set airduct mode to cooling mode for cooling
M106 P2 S255 ; turn on auxiliary fan for cooling
M106 P10 S255 ; turn on auxiliary fan for cooling
M106 P3 S180 ; turn on chamber fan for cooling
;M140 S0 ; stop heatbed from heating
M1002 gcode_claim_action : 29
M191 S0 ; wait for chamber temp
M106 P2 S0 ; turn off auxiliary fan → left Aux
M106 P10 S0 ; turn off auxiliary fan → right Aux
;M142 P6 R30 S40 U0.3 V0.8 ; set PLA/TPU/PETG exhaust chamber autocooling

; — X2D: material-dependent exhaust/chamber autocooling —
{if (min_vitrification_temperature <= 55)}
;PLA/TPU-like: earlier and stronger exhaust
M142 P6 R30 S40 U0.5 V1.0
{elsif (min_vitrification_temperature <= 85)}
;PETG-like: later and softer exhaust
M142 P6 R38 S50 U0.5 V0.8
{else}
;ABS/ASA/PC-like: keep chamber warmer
M142 P6 R45 S60 U0.40 V0.7
{endif}

;===== DEBUG PLACEHOLDERS =====
….

layer change:
;======== X2D layer_change gcode ==========
;===== X2D M142 P1 aux control + chamber safety =====

; update layer progress
M73 L{layer_num+1}
M991 S0 P{layer_num} ;notify layer change

; — X2D: no aux during first no-cooling layers —
; M142 P1 is intentionally not active during first cooling-off layers

{if (layer_num + 1 > close_fan_the_first_x_layers[current_extruder])}

; — low vitrification materials: PLA / TPU-like —
{if (min_vitrification_temperature <= 55)}
M142 P1 R32 S40 U{additional_cooling_fan_speed[current_extruder]/100.0} V{(additional_cooling_fan_speed[current_extruder]+30)/100.0} O50

; — medium vitrification materials: PETG-like —
{elsif (min_vitrification_temperature <= 85)}
M142 P1 R38 S52 U{additional_cooling_fan_speed[current_extruder]/100.0} V{(additional_cooling_fan_speed[current_extruder]+20)/100.0} O62

; — high temp materials: ABS/ASA/PC-like —
{else}
M142 P1 R45 S60 U{additional_cooling_fan_speed[current_extruder]/100.0} V{(additional_cooling_fan_speed[current_extruder]+10)/100.0} O75
{endif}

{endif}

layer change:
….
G1 Y256 F18000

; — X2D: apply M142 P1 aux control for next filament —
; no aux during first no-cooling layers
{if (overall_chamber_temperature < 40)}
{if (layer_num + 1 <= close_fan_the_first_x_layers[next_extruder])}
M106 P2 S0
M106 P10 S0
{else}

; — X2D M142 P1 aux control for next filament —
; U = lower aux level from filament aux fan setting
; V = upper aux level depending on material class
; O = alarm / critical chamber threshold

{if (min_vitrification_temperature <= 55)}
; PLA / TPU-like: earlier, stronger, lower alarm threshold
{if (nozzle_diameter <= 0.25)}
M142 P1 R30 S38 U{additional_cooling_fan_speed[next_extruder]/100.0} V{min(1.0,(additional_cooling_fan_speed[next_extruder]+30)/100.0)} O48
{elsif (nozzle_diameter <= 0.45)}
M142 P1 R32 S40 U{additional_cooling_fan_speed[next_extruder]/100.0} V{min(1.0,(additional_cooling_fan_speed[next_extruder]+30)/100.0)} O50
{else}
M142 P1 R34 S42 U{additional_cooling_fan_speed[next_extruder]/100.0} V{min(1.0,(additional_cooling_fan_speed[next_extruder]+30)/100.0)} O52
{endif}

{elsif (min_vitrification_temperature <= 85)}
; PETG-like: later, softer, higher alarm threshold
{if (nozzle_diameter <= 0.25)}
M142 P1 R36 S48 U{additional_cooling_fan_speed[next_extruder]/100.0} V{min(1.0,(additional_cooling_fan_speed[next_extruder]+20)/100.0)} O58
{elsif (nozzle_diameter <= 0.45)}
M142 P1 R38 S52 U{additional_cooling_fan_speed[next_extruder]/100.0} V{min(1.0,(additional_cooling_fan_speed[next_extruder]+20)/100.0)} O62
{else}
M142 P1 R40 S55 U{additional_cooling_fan_speed[next_extruder]/100.0} V{min(1.0,(additional_cooling_fan_speed[next_extruder]+20)/100.0)} O65
{endif}

{else}
; ABS / ASA / PC-like: keep chamber warmer
{if (nozzle_diameter <= 0.25)}
M142 P1 R42 S56 U{additional_cooling_fan_speed[next_extruder]/100.0} V{min(1.0,(additional_cooling_fan_speed[next_extruder]+10)/100.0)} O70
{elsif (nozzle_diameter <= 0.45)}
M142 P1 R45 S60 U{additional_cooling_fan_speed[next_extruder]/100.0} V{min(1.0,(additional_cooling_fan_speed[next_extruder]+10)/100.0)} O75
{else}
M142 P1 R48 S65 U{additional_cooling_fan_speed[next_extruder]/100.0} V{min(1.0,(additional_cooling_fan_speed[next_extruder]+10)/100.0)} O80
{endif}
{endif}

{endif}
{endif}

;not set fan changing filament

this will get more control over the fans while still having some automated ventilation and alarm settings active.

2 Likes

Hi,

Is it possible to add M142 P1 fan control to filament settings?

it’s make me crazy - print only PETG, L&R AUX fan go up to 100%, and after 20-30min model warping from the bad…

X2D PETG.3mf (28.6 KB)

With this setup, the left fan (L) is set to 50%, the right fan (R) to 60%, and the rear exhaust fan to 80%. Once the print starts, you can manually adjust these values, and they will remain at whatever settings you choose.

It is possible to control fan speeds through filament profiles, but in my case that’s not ideal. As temperatures change throughout a print depending on the model, the automatic settings can still end up pushing the fans harder than necessary.

In my opinion (and I’m not an expert), creating reliable automatic fan control based on chamber or environmental temperatures takes a lot of time and effort. Bambu has come close, but for example, when using PLA as an interface material, the fan settings can still be too aggressive. There also isn’t a universal setting that works well for every model and print size.

For the types of models I print, manual fan adjustments have given me the best results.

1 Like

Does the automatic “strong cooling” not override your fan setting on every layer change? I tried capping the aux fan speed in the filament settings, but it just automatically jumps to 80%. Is there not any fix besides editing the G-Code manually?

i added that in my example.. you can set M142 P1 by using the parameter additional_cooling_fan_speed
in my example i use the settings of the filament parameter for lower threshold and then add +20% for the higher threshold value. This will result in the fan using the settings of the filament most of the time, but if the temperature reaches the limit value it allows to ramp up the speed to a maximum of additional_cooling_fan_speed + 20%

This setting will also take the filament settings for first layers into account. If no colling is set for the first x layers the aux fans will be disabled.

For dual nozzle prints it will switch the settings dependent on the active nozzle and choosen filament. For me it works well, I print petg and use Pla for support layer. No more warping..

The exhaust fan is controlled in the start code dependend on the material with the lowest vitrification temperature used in the project..

For bambu studio:
Startcode:

;M1002 set_flag extrude_cali_flag=1
;M1002 set_flag g29_before_print_flag=1
;M1002 set_flag auto_cali_toolhead_offset_flag=1
;M1002 set_flag build_plate_detect_flag=1

;======== X2D start gcode==========
;===== 2026/05/18 =====

  M140 S[bed_temperature_initial_layer_single] ; heat heatbed first
  M993 A0 B0 C0 ; nozzle cam detection not allowed.
  M400
  ;M73 P99

;=====printer start sound ===================
M17
M400 S1
M1006 S1
M1006 A53 B9 L50 C53 D9 M50 E53 F9 N50
M1006 A56 B9 L50 C56 D9 M50 E56 F9 N50
M1006 A61 B9 L50 C61 D9 M50 E61 F9 N50
M1006 A53 B9 L50 C53 D9 M50 E53 F9 N50
M1006 A56 B9 L50 C56 D9 M50 E56 F9 N50
M1006 A61 B18 L50 C61 D18 M50 E61 F18 N50
M1006 W
;=====printer start sound ===================

  M1012.1 T1100
  M620 M ;enable remap
  M622.1 S0
  G383.4

;===== avoid end stop =================
  G91
  G380 S2 Z22 F1200
  G380 S2 Z-12 F1200
  G90
;===== avoid end stop =================

;===== reset machine status =================
  M204 S10000
  M630 S0 P1
  G90
  M17 D ; reset motor current to default
  M960 S5 P1 ; turn on logo lamp
  M220 S100 ;Reset Feedrate
  M1002 set_gcode_claim_speed_level: 5
  M221 S100 ;Reset Flowrate
  M73.2   R1.0 ;Reset left time magnitude
  G29.1 Z{+0.0} ; clear z-trim value first
  M983.1 M1
  M982.2 S1 ; turn on cog noise reduction
;===== reset machine status =================

;==== set airduct mode ====
{if (overall_chamber_temperature >= 40)}
M145 P1 ; set airduct mode to heating mode for heating
M106 P2 S0 ; turn off auxiliary fan
M106 P10 S255 ; turn on filter fan
{else}
M145 P0 ; set airduct mode to cooling mode for cooling
M106 P2 S255 ; turn on auxiliary fan for cooling
M106 P10 S255 ; turn on auxiliary fan for cooling
M106 P3 S127 ; turn on chamber fan for cooling
;M140 S0 ; stop heatbed from heating
M1002 gcode_claim_action : 29
M191 S0 ; wait for chamber temp
; after cooldown: release aux fans, layer-change code will control M142 P1 later
M106 P2 S0 ; turn off auxiliary fan left
M106 P10 S0 ; turn off auxiliary fan right
; material-dependent exhaust/chamber autocooling only
{if (min_vitrification_temperature <= 55)}
M142 P6 R30 S40 U0.5 V1.0 ; PLA / TPU-like: stronger exhaust safety
{elsif (min_vitrification_temperature <= 85)}
M142 P6 R38 S50 U0.5 V0.8 ; PETG-like: medium exhaust safety
{else}
M142 P6 R45 S60 U0.4 V0.7 ; ABS / ASA / PC-like: keep chamber warmer
{endif}

{endif}
;==== set airduct mode ====

;===== start to heat heatbed & hotend==========
  M1002 gcode_claim_action : 2
  M1002 set_filament_type:{filament_type[initial_no_support_filament_id]}

  ;===== set chamber temperature ==========
  {if (overall_chamber_temperature >= 40)}
    M145 P1 ; set airduct mode to heating mode
    M141 S[overall_chamber_temperature] ; Let Chamber begin to heat
  {endif}
;===== set chamber temperature ==========

  G29.2 S0 ; avoid invalid abl data

;===== first homing start =====
  M1002 gcode_claim_action : 13
  G28 X T300 R
  G150.1 F8000 ; wipe mouth to avoid filament stick to heatbed
  G150.3
  M972 S24 P0
  M1002 gcode_claim_action : 74 ; Heatbed surface foreign object detection
  M972 S26 P0 C0
  G90
  M83
  G1 Y128 F30000
  G1 X128
  G28 Z P0 T400
  M400
;===== first homign end =====

;===== detection start =====
  M1002 gcode_claim_action : 11

      M104 S0 T0
      M104 S0 T1
      M562 P1 E0 B1
      M562 P2 E0 B1
      M18 E
      M400 P200
      M1028 S1
      M972 S19 P0   ;heatbed detection
      M972 S31 P0   ;toolhead camera dirt detection
      M1002 gcode_claim_action : 73 ; Build plate alignment detection
      M972 S34 P0   ;print plate deviation detection
      M1028 S0
      M562 P1 E1 B1
      M562 P2 E1 B1
      M17 D

  ;M400
  M104 S{nozzle_temperature_initial_layer[initial_no_support_filament_id]} T{filament_map[initial_no_support_filament_id] % 2} ; rise temp in advance

  {if max_print_z >= 145}
    G151 P{filament_map[initial_no_support_filament_id] % 2} M ; plug the heat nozzle
    M1002 gcode_claim_action : 75 ;  Detect obstacles at the botton of the heated bed
    G3811 Z{max_print_z}  ; Detect obstacles at the bottom of the heated bed
  {endif}
;===== detection end =====

;===== prepare print temperature and material ==========
  M104 S{nozzle_temperature_initial_layer[initial_no_support_filament_id]-40} A ; rise temp in advance
  M400
  M211 X0 Y0 Z0 ;turn off soft endstop
  M975 S1 ; turn on input shaping

  G29.2 S0 ; avoid invalid abl data
  G150.3
{if ((filament_type[initial_no_support_filament_id] == "PLA") || (filament_type[initial_no_support_filament_id] == "PLA-CF") || (filament_type[initial_no_support_filament_id] == "PETG")) && (nozzle_diameter_at_nozzle_id[initial_nozzle_id] == 0.2)}
M620.10 A0 F74.8347 H{nozzle_diameter_at_nozzle_id[initial_nozzle_id]} T{flush_temperatures[initial_no_support_filament_id]} P{nozzle_temperature_initial_layer[initial_no_support_filament_id]} S1
M620.10 A1 F74.8347 H{nozzle_diameter_at_nozzle_id[initial_nozzle_id]} T{flush_temperatures[initial_no_support_filament_id]} P{nozzle_temperature_initial_layer[initial_no_support_filament_id]} S1
{else}
M620.10 A0 F{flush_volumetric_speeds[initial_no_support_filament_id]/2.4053*60} H{nozzle_diameter_at_nozzle_id[initial_nozzle_id]} T{flush_temperatures[initial_no_support_filament_id]} P{nozzle_temperature_initial_layer[initial_no_support_filament_id]} S1
M620.10 A1 F{flush_volumetric_speeds[initial_no_support_filament_id]/2.4053*60} H{nozzle_diameter_at_nozzle_id[initial_nozzle_id]} T{flush_temperatures[initial_no_support_filament_id]} P{nozzle_temperature_initial_layer[initial_no_support_filament_id]} S1
{endif}

 M620.11 P0 L0 I[initial_no_support_filament_id] B[initial_no_support_hotend] E0
 M620.11 K0 I[initial_no_support_filament_id] B[initial_no_support_hotend] R0

  M620 S[initial_no_support_filament_id]A H[initial_no_support_hotend] B   ; switch material if AMS exist
  M620.22 I[initial_no_support_filament_id] P1    ; enable remote extruder runout auto purge.
  M1002 gcode_claim_action : 4
  M1002 set_filament_type:UNKNOWN
  M400
  T[initial_no_support_filament_id] H[initial_no_support_hotend]
  M400
  M628 S0
  M629
  M400
  M1002 set_filament_type:{filament_type[initial_no_support_filament_id]}
  M621 S[initial_no_support_filament_id]A B
  M104 S{nozzle_temperature_initial_layer[initial_no_support_filament_id]}
  M400
  M106 P1 S0
  M400
  G29.2 S1
;===== prepare print temperature and material ==========

;===== auto extrude cali start =========================
  M975 S1
  M1002 judge_flag extrude_cali_flag
  M622 J0
    M983.3 F{filament_max_volumetric_speed[initial_no_support_filament_id]/2.4} A0.4 ; cali dynamic extrusion compensation
  M623

  M622 J1
    M1002 set_filament_type:{filament_type[initial_no_support_filament_id]}
    M1002 gcode_claim_action : 8
    M109 S{nozzle_temperature[initial_no_support_filament_id]}
    G90
    M83
    M983.3 F{filament_max_volumetric_speed[initial_no_support_filament_id]/2.4} A0.4 ; cali dynamic extrusion compensation
    M400
    M106 P1 S255
    M400 S5
    M106 P1 S0
    G150.3
  M623

  M622 J2
    M1002 set_filament_type:{filament_type[initial_no_support_filament_id]}
    M1002 gcode_claim_action : 8
    M109 S{nozzle_temperature[initial_no_support_filament_id]}
    G90
    M83
    M983.3 F{filament_max_volumetric_speed[initial_no_support_filament_id]/2.4} A0.4 ; cali dynamic extrusion compensation
    M400
    M106 P1 S255
    M400 S5
    M106 P1 S0
    G150.3
  M623
;===== auto extrude cali end =========================

  {if hold_chamber_temp_for_flat_print}
    G150.3
    M1002 gcode_claim_action : 58
    M104 S{first_layer_temperature[initial_no_support_filament_id]}
    {if bed_temperature_initial_layer_single > 89}
        {if overall_chamber_temperature < 40}
            M1030 S1200
            SYNC R0 T1200
        {else}
            M1030 S600
            SYNC R0 T600
        {endif}
    {else}
        M1030 S300
        SYNC R0 T300
    {endif}
    M1030 C
  {endif}

  {if filament_type[initial_filament_id] == "TPU" || filament_type[initial_filament_id] == "PVA"}
  {else}
    M83
    G1 E-3 F1800
    M400 P500
  {endif}
  G150.2
  G150.1 F8000
  G150.2
  G150.1 F8000

  G91
  G1 Y-16 F12000 ; move away from the trash bin
  G90
  M400

  M104 S{nozzle_temperature_initial_layer[initial_no_support_filament_id]-80} A

;===== wipe right nozzle start =====
  M1002 gcode_claim_action : 14
  G150 T{nozzle_temperature_initial_layer[initial_no_support_filament_id]}
  M400
;===== wipe left nozzle end =====

{if filament_type[initial_filament_id] == "PC"}
  M109 S170 A
{else}
  M109 S140 A
{endif}
  M106 S0 ; turn off fan , too noisy
  G91
  G1 Z5 F1200
  G90
  M400
  G150.1

{if (overall_chamber_temperature >= 40)}
M1002 gcode_claim_action : 49
M191 S[overall_chamber_temperature] ; wait for chamber temp
{endif}

;===== z ofst cali start =====
  M190 S[bed_temperature_initial_layer_single]; ensure bed temp
  G383 O0 M1 T140
  M400
;===== z ofst cali end =====
G90
M83
G0 Y200 F18000

;===== bed leveling ==================================
  M1002 gcode_claim_action : 54
  M190 S[bed_temperature_initial_layer_single]; ensure bed temp
  M109 S140 A
  M106 S0 ; turn off fan , too noisy
  M1002 judge_flag g29_before_print_flag
  M622 J1
    M1002 gcode_claim_action : 1
    {if hold_chamber_temp_for_flat_print}
      G29 H R
    {else}
      G29 A1 X{first_layer_print_min[0]} Y{first_layer_print_min[1]} I{first_layer_print_size[0]} J{first_layer_print_size[1]} R
    {endif}
    M400
  M623

  M622 J2
    M1002 gcode_claim_action : 1
    {if hold_chamber_temp_for_flat_print}
      G29 H R
    {else}
      G29 A2 X{first_layer_print_min[0]} Y{first_layer_print_min[1]} I{first_layer_print_size[0]} J{first_layer_print_size[1]} R
    {endif}
    M400
  M623

  M622 J0
    G28 R
  M623
  G29.2 S1
;===== bed leveling end ================================

; cali eddy z pos
;G383.13 T1 C1

M104 S{nozzle_temperature_initial_layer[initial_no_support_filament_id]} A
;===== mech mode sweep start =====
  M1002 gcode_claim_action : 3
  G90
  G1 X128 Y128 F20000
  G1 Z5 F1200
  M400 P200
  M970.3 Q1 A5 K0 O1
  M974 Q1 S2 P0
  M970.3 Q0 A7 K0 O1
  M970.2 Q0 W73 K1 Z0.01
  M974 Q0 S2 P0
  M975 S1
  M400
;===== mech mode sweep end =====

M104 S{nozzle_temperature_initial_layer[initial_filament_id]} A
G150.3

;===== xy ofst cali start =====
M1002 judge_flag auto_cali_toolhead_offset_flag

M622 J0
    M1012.5 N1 R1
M623

M622 J1
    M1002 gcode_claim_action : 39
    M141 S0
    M620.17 T0 S{nozzle_temperature_initial_layer[(first_non_support_filaments[0] != -1 ? first_non_support_filaments[0] : first_filaments[0])]} L{(first_non_support_filaments[0] != -1 ? first_non_support_filaments[0] : first_filaments[0])}
    M620.17 T1 S{nozzle_temperature_initial_layer[(first_non_support_filaments[1] != -1 ? first_non_support_filaments[1] : first_filaments[1])]} L{(first_non_support_filaments[1] != -1 ? first_non_support_filaments[1] : first_filaments[1])}
    M620 D[initial_no_support_hotend]
    G383 O1 T{nozzle_temperature_initial_layer[initial_no_support_filament_id]} L{initial_no_support_filament_id}
    M141 S[overall_chamber_temperature]
M623

M622 J2
    M1002 gcode_claim_action : 39
    M141 S0
    M620.17 T0 S{nozzle_temperature_initial_layer[(first_non_support_filaments[0] != -1 ? first_non_support_filaments[0] : first_filaments[0])]} L{(first_non_support_filaments[0] != -1 ? first_non_support_filaments[0] : first_filaments[0])}
    M620.17 T1 S{nozzle_temperature_initial_layer[(first_non_support_filaments[1] != -1 ? first_non_support_filaments[1] : first_filaments[1])]} L{(first_non_support_filaments[1] != -1 ? first_non_support_filaments[1] : first_filaments[1])}
    M620 D[initial_no_support_hotend]
    G383.3 T{nozzle_temperature_initial_layer[initial_no_support_filament_id]} L{initial_no_support_filament_id}
    M141 S[overall_chamber_temperature]
M623
;===== xy ofst cali end =====

  M104 S{nozzle_temperature_initial_layer[initial_filament_id]} A

 G150.3 ; move to garbage can to wait for temp

;===== wait temperature reaching the reference value =======
  M140 S[bed_temperature_initial_layer_single]
  M190 S[bed_temperature_initial_layer_single]

  ;========turn off light and fans =============
  M960 S1 P0 ; turn off laser
  M960 S2 P0 ; turn off laser
  M106 S0 ; turn off cooling fan

;===== wait temperature reaching the reference value =======

  M1002 gcode_claim_action : 255
  M400
  M975 S1 ; turn on mech mode supression
  M983.4 S0 ; turn off deformation compensation

;============switch again==================
  M211 X0 Y0 Z0 ;turn off soft endstop
  G91
  G1 Z6 F1200
  G90
  M1002 set_filament_type:{filament_type[initial_no_support_filament_id]}
  M620 S[initial_no_support_filament_id]A H[initial_no_support_hotend] B
  M620.22 I[initial_no_support_filament_id] P1    ; enable remote extruder runout auto purge.
  M400
  T[initial_no_support_filament_id] H[initial_no_support_hotend]
  M400
  M628 S0
  M629
  M400
  M621 S[initial_no_support_filament_id]A B
;============switch again==================

;===== for Textured PEI Plate , lower the nozzle as the nozzle was touching topmost of the texture when homing ==
  {if bed_temperature_initial_layer_single > 70}
    {if curr_bed_type=="Textured PEI Plate"}
      G29.1 Z{-0.003} ; for Textured PEI Plate
    {else}
      G29.1 Z{0.017}
    {endif}
  {else}
    {if curr_bed_type=="Textured PEI Plate"}
      G29.1 Z{0.002} ; for Textured PEI Plate
    {else}
      G29.1 Z{0.022}
    {endif}
  {endif}

;===== nozzle load line ===============================
M1002 gcode_claim_action : 51
  G29.2 S1 ; ensure z comp turn on
  G90
  M83
  M400 P50
  M500 D1
  M400 S3
  M109 S{nozzle_temperature_initial_layer[initial_no_support_filament_id]}
  G0 X100 Y0 F24000
  M400
  ;G130 O0 X100 Y-0.4 Z0.6 F{filament_max_volumetric_speed[initial_no_support_filament_id]/2/2.4053} L40 E20 D5
  G130 O0 X100 Y-0.2 Z0.6 F{filament_max_volumetric_speed[initial_no_support_filament_id]/2/2.4053} L40 E12 D4
G90
  G90
  M83
  G1 Z1
  M400
;===== noozle load line end ===========================
M1002 gcode_claim_action : 0
  G29.99

;M993 A1 B1 C1 ; nozzle cam detection allowed.

M620.6 I[initial_no_support_filament_id] H[initial_no_support_hotend] W1 ;enable ams air printing detect


{if (filament_type[initial_no_support_filament_id] == "TPU")}
M1015.3 S1 H{nozzle_diameter_at_nozzle_id[initial_nozzle_id]};enable tpu clog detect
{else}
M1015.3 S0;disable tpu clog detect
{endif}

{if (filament_type[initial_no_support_filament_id] == "PLA") ||  (filament_type[initial_no_support_filament_id] == "PETG")
 ||  (filament_type[initial_no_support_filament_id] == "PLA-CF")  ||  (filament_type[initial_no_support_filament_id] == "PETG-CF")}
M1015.4 S1 K1 H{nozzle_diameter_at_nozzle_id[initial_nozzle_id]} ;enable E air printing detect
{else}
M1015.4 S0 K0 H{nozzle_diameter_at_nozzle_id[initial_nozzle_id]} ;disable E air printing detect
{endif}


layer change

;======== X2D layer_change gcode ==========
;===== X2D initial aux from filament + M142 P1 after first layers =====
{if (layer_num + 1 <= close_additional_fan_first_x_layers[current_filament_id])}
{if (overall_chamber_temperature < 40)}
M106 P2 S{int(first_x_layer_fan_speed[current_filament_id]*255.0/100.0)}
M106 P10 S{int(first_x_layer_fan_speed[current_filament_id]*255.0/100.0)}
{endif}
;not reset fan

; --- optional linear ramp from initial aux to normal aux ---
{elsif (layer_num + 1 < additional_fan_full_speed_layer[current_filament_id] && additional_fan_full_speed_layer[current_filament_id] > close_additional_fan_first_x_layers[current_filament_id])}
{if (overall_chamber_temperature < 40)}
M106 P2 S{int((first_x_layer_fan_speed[current_filament_id] + (additional_cooling_fan_speed[current_filament_id] - first_x_layer_fan_speed[current_filament_id]) * (layer_num + 1 - close_additional_fan_first_x_layers[current_filament_id]) / max(additional_fan_full_speed_layer[current_filament_id] - close_additional_fan_first_x_layers[current_filament_id], 1)) * 255.0/100.0)}
M106 P10 S{int((first_x_layer_fan_speed[current_filament_id] + (additional_cooling_fan_speed[current_filament_id] - first_x_layer_fan_speed[current_filament_id]) * (layer_num + 1 - close_additional_fan_first_x_layers[current_filament_id]) / max(additional_fan_full_speed_layer[current_filament_id] - close_additional_fan_first_x_layers[current_filament_id], 1)) * 255.0/100.0)}
{endif}
;not reset fan

; --- after first/ramp layers: X2D M142 P1 aux control ---
{else}
{if (overall_chamber_temperature < 40)}

; --- low vitrification materials: PLA / TPU-like ---
{if (min_vitrification_temperature <= 55)}
{if (nozzle_diameter_at_nozzle_id[current_nozzle_id] <= 0.25)}
M142 P1 R30 S38 U{additional_cooling_fan_speed[current_filament_id]/100.0} V{min(1.0,(additional_cooling_fan_speed[current_filament_id]+20)/100.0)} O48
{elsif (nozzle_diameter_at_nozzle_id[current_nozzle_id] <= 0.45)}
M142 P1 R35 S42 U{additional_cooling_fan_speed[current_filament_id]/100.0} V{min(1.0,(additional_cooling_fan_speed[current_filament_id]+20)/100.0)} O50
{else}
M142 P1 R34 S42 U{additional_cooling_fan_speed[current_filament_id]/100.0} V{min(1.0,(additional_cooling_fan_speed[current_filament_id]+20)/100.0)} O52
{endif}

; --- medium vitrification materials: PETG-like ---
{elsif (min_vitrification_temperature <= 85)}
{if (nozzle_diameter_at_nozzle_id[current_nozzle_id] <= 0.25)}
M142 P1 R36 S48 U{additional_cooling_fan_speed[current_filament_id]/100.0} V{min(1.0,(additional_cooling_fan_speed[current_filament_id]+20)/100.0)} O58
{elsif (nozzle_diameter_at_nozzle_id[current_nozzle_id] <= 0.45)}
M142 P1 R40 S52 U{additional_cooling_fan_speed[current_filament_id]/100.0} V{min(1.0,(additional_cooling_fan_speed[current_filament_id]+20)/100.0)} O62
{else}
M142 P1 R42 S55 U{additional_cooling_fan_speed[current_filament_id]/100.0} V{min(1.0,(additional_cooling_fan_speed[current_filament_id]+20)/100.0)} O65
{endif}

; --- high temp materials: ABS / ASA / PC-like ---
{else}
{if (nozzle_diameter_at_nozzle_id[current_nozzle_id] <= 0.25)}
M142 P1 R42 S56 U{additional_cooling_fan_speed[current_filament_id]/100.0} V{min(1.0,(additional_cooling_fan_speed[current_filament_id]+10)/100.0)} O70
{elsif (nozzle_diameter_at_nozzle_id[current_nozzle_id] <= 0.45)}
M142 P1 R45 S60 U{additional_cooling_fan_speed[current_filament_id]/100.0} V{min(1.0,(additional_cooling_fan_speed[current_filament_id]+10)/100.0)} O75
{else}
M142 P1 R48 S65 U{additional_cooling_fan_speed[current_filament_id]/100.0} V{min(1.0,(additional_cooling_fan_speed[current_filament_id]+10)/100.0)} O80
{endif}
{endif}

{else}
;not reset filter fan in warm chamber mode
{endif}
;not reset fan
{endif}

; update layer progress
M73 L{layer_num+1}
M991 S0 P{layer_num} ;notify layer change

filament change

======== X2D filament_change gcode ==========
;===== 2026/05/15 =====

M620 S[next_filament_id]A B H[next_hotend]
;M204 S9000
{if toolchange_count > 1 && (z_hop_types[current_filament_id] == 0 || z_hop_types[current_filament_id] == 3)}
G17
G2 Z{z_after_toolchange + 0.4} I0.86 J0.86 P1 F10000 ; spiral lift a little from second lift
{endif}

;nozzle_change_gcode

G1 Z{max_layer_z + 3.0} F1200

M400
M106 P1 S0

{if toolchange_count == 2}
; get travel path for change filament
;M620.1 X[travel_point_1_x] Y[travel_point_1_y] F21000 P0
;M620.1 X[travel_point_2_x] Y[travel_point_2_y] F21000 P1
;M620.1 X[travel_point_3_x] Y[travel_point_3_y] F21000 P2
{endif}

{if ((filament_type[current_filament_id] == "PLA") || (filament_type[current_filament_id] == "PLA-CF") || (filament_type[current_filament_id] == "PETG")) && (nozzle_diameter_at_nozzle_id[current_nozzle_id] == 0.2)}
M620.10 A0 F74.8347 L[flush_length] H{nozzle_diameter_at_nozzle_id[current_nozzle_id]} T{flush_temperatures[current_filament_id]} P[old_filament_temp] S1
{else}
M620.10 A0 F{flush_volumetric_speeds[current_filament_id]/2.4053*60} L[flush_length] H{nozzle_diameter_at_nozzle_id[current_nozzle_id]} T{flush_temperatures[current_filament_id]} P[old_filament_temp] S1
{endif}

{if ((filament_type[next_filament_id] == "PLA") || (filament_type[next_filament_id] == "PLA-CF") || (filament_type[next_filament_id] == "PETG")) && (nozzle_diameter_at_nozzle_id[next_nozzle_id] == 0.2)}
M620.10 A1 F74.8347 L[flush_length] H{nozzle_diameter_at_nozzle_id[next_nozzle_id]} T{flush_temperatures[next_filament_id]} P[new_filament_temp] S1
{else}
M620.10 A1 F{flush_volumetric_speeds[next_filament_id]/2.4053*60} L[flush_length] H{nozzle_diameter_at_nozzle_id[next_nozzle_id]} T{flush_temperatures[next_filament_id]} P[new_filament_temp] S1
{endif}

M620.15 C{new_filament_temp - filament_cooling_before_tower[next_filament_id]}

{if long_retraction_when_cut}
M620.11 P1 L0 I[current_filament_id] B[current_hotend] E-{retraction_distance_when_cut} F{max((flush_volumetric_speeds[current_filament_id]/2.4053*60), 200)}
{else}
M620.11 P0 L0 I[current_filament_id] B[current_hotend] E0
{endif}

{if long_retraction_when_ec}
M620.11 K1 I[current_filament_id] B[current_hotend] R{retraction_distance_when_ec} F{max((flush_volumetric_speeds[current_filament_id]/2.4053*60), 200)}
{else}
M620.11 K0 I[current_filament_id] B[current_hotend] R0
{endif}

M620.22 I[next_filament_id] P1    ; enable remote extruder runout auto purge.

T[next_filament_id] H[next_hotend]

;deretract
{if filament_type[next_filament_id] == "TPU"}
{else}
{if filament_type[next_filament_id] == "PA"}
;VG1 E1 F{max(new_filament_e_feedrate, 200)}
;VG1 E1 F{max(new_filament_e_feedrate/2, 100)}
{else}
;VG1 E4 F{max(new_filament_e_feedrate, 200)}
;VG1 E4 F{max(new_filament_e_feedrate/2, 100)}
{endif}
{endif}

; VFLUSH_START
{if flush_length>41.5}
;VG1 E41.5 F{min(old_filament_e_feedrate,new_filament_e_feedrate)}
;VG1 E{flush_length-41.5} F{new_filament_e_feedrate}
{else}
;VG1 E{flush_length} F{min(old_filament_e_feedrate,new_filament_e_feedrate)}
{endif}
SYNC T{ceil(flush_length / 125) * 5}
; VFLUSH_END

M1002 set_filament_type:{filament_type[next_filament_id]}

M400
M83
{if next_filament_id < 255}
M620.10 R{retract_length_toolchange[filament_map[next_filament_id]-1]}
M628 S0
;VM109 S[new_filament_temp]
M629
M400

;prime_tower_interface
{if is_prime_tower_interface && filament_tower_interface_purge_volume !=0}
G150.1
M620.13 W0 L{filament_tower_interface_purge_volume} T{filament_tower_interface_print_temp} R0.0
{endif}
;prime_tower_interface

M983.3 F{filament_max_volumetric_speed[next_filament_id]/2.4} A0.4 R{retract_length_toolchange[filament_map[next_filament_id]-1]}

M400

G1 Z{max_layer_z + 3.0} F3000

{else}
G1 X[x_after_toolchange] Y[y_after_toolchange] Z[z_after_toolchange] F12000
{endif}


M621 S[next_filament_id]A B

M622.1 S0 ;for prev version, default skip
M1002 judge_flag powerloss_resume_flag
M622 J1
M983.3 F{filament_max_volumetric_speed[next_filament_id]/2.4} A0.4 R{retract_length_toolchange[filament_map[next_filament_id]-1]}
M400
G1 Z{max_layer_z + 3.0} F3000
M1002 set_flag powerloss_resume_flag=0
M623

M620.6 I[next_filament_id] H[next_hotend] W1 ;enable ams air printing detect

{if (filament_type[next_filament_id] == "TPU")}
M1015.3 S1 H{nozzle_diameter_at_nozzle_id[next_nozzle_id]};enable tpu clog detect
{else}
M1015.3 S0;disable tpu clog detect
{endif}

{if (filament_type[next_filament_id] == "PLA") ||  (filament_type[next_filament_id] == "PETG")
 ||  (filament_type[next_filament_id] == "PLA-CF")  ||  (filament_type[next_filament_id] == "PETG-CF")}
M1015.4 S1 K1 H{nozzle_diameter_at_nozzle_id[next_nozzle_id]} ;enable E air printing detect
{else}
M1015.4 S0 K0 H{nozzle_diameter_at_nozzle_id[next_nozzle_id]} ;disable E air printing detect
{endif}

{if layer_z <= (initial_layer_print_height + 0.001)}
M204 S[initial_layer_acceleration]
{else}
M204 S[travel_acceleration]
{endif}

G1 Y256 F18000


; --- X2D: apply aux fan logic for next filament after toolchange ---
{if (overall_chamber_temperature < 40)}

; --- first aux layers exactly from next filament setting ---
{if (layer_num + 1 <= close_additional_fan_first_x_layers[next_filament_id])}
M106 P2 S{int(first_x_layer_fan_speed[next_filament_id]*255.0/100.0)}
M106 P10 S{int(first_x_layer_fan_speed[next_filament_id]*255.0/100.0)}

; --- optional linear ramp from initial aux to normal aux ---
{elsif (layer_num + 1 < additional_fan_full_speed_layer[next_filament_id] && additional_fan_full_speed_layer[next_filament_id] > close_additional_fan_first_x_layers[next_filament_id])}
M106 P2 S{int((first_x_layer_fan_speed[next_filament_id] + (additional_cooling_fan_speed[next_filament_id] - first_x_layer_fan_speed[next_filament_id]) * (layer_num + 1 - close_additional_fan_first_x_layers[next_filament_id]) / max(additional_fan_full_speed_layer[next_filament_id] - close_additional_fan_first_x_layers[next_filament_id], 1)) * 255.0/100.0)}
M106 P10 S{int((first_x_layer_fan_speed[next_filament_id] + (additional_cooling_fan_speed[next_filament_id] - first_x_layer_fan_speed[next_filament_id]) * (layer_num + 1 - close_additional_fan_first_x_layers[next_filament_id]) / max(additional_fan_full_speed_layer[next_filament_id] - close_additional_fan_first_x_layers[next_filament_id], 1)) * 255.0/100.0)}

; --- after first/ramp layers: X2D M142 P1 aux control for next filament ---
{else}

; --- low vitrification materials: PLA / TPU-like ---
{if (min_vitrification_temperature <= 55)}
{if (nozzle_diameter_at_nozzle_id[next_nozzle_id] <= 0.25)}
M142 P1 R32 S40 U{additional_cooling_fan_speed[next_filament_id]/100.0} V{min(1.0,(additional_cooling_fan_speed[next_filament_id]+20)/100.0)} O48
{elsif (nozzle_diameter_at_nozzle_id[next_nozzle_id] <= 0.45)}
M142 P1 R35 S42 U{additional_cooling_fan_speed[next_filament_id]/100.0} V{min(1.0,(additional_cooling_fan_speed[next_filament_id]+20)/100.0)} O50
{else}
M142 P1 R34 S42 U{additional_cooling_fan_speed[next_filament_id]/100.0} V{min(1.0,(additional_cooling_fan_speed[next_filament_id]+20)/100.0)} O52
{endif}

; --- medium vitrification materials: PETG-like ---
{elsif (min_vitrification_temperature <= 85)}
{if (nozzle_diameter_at_nozzle_id[next_nozzle_id] <= 0.25)}
M142 P1 R36 S48 U{additional_cooling_fan_speed[next_filament_id]/100.0} V{min(1.0,(additional_cooling_fan_speed[next_filament_id]+20)/100.0)} O58
{elsif (nozzle_diameter_at_nozzle_id[next_nozzle_id] <= 0.45)}
M142 P1 R40 S52 U{additional_cooling_fan_speed[next_filament_id]/100.0} V{min(1.0,(additional_cooling_fan_speed[next_filament_id]+20)/100.0)} O62
{else}
M142 P1 R42 S55 U{additional_cooling_fan_speed[next_filament_id]/100.0} V{min(1.0,(additional_cooling_fan_speed[next_filament_id]+20)/100.0)} O65
{endif}

; --- high temp materials: ABS / ASA / PC-like ---
{else}
{if (nozzle_diameter_at_nozzle_id[next_nozzle_id] <= 0.25)}
M142 P1 R42 S56 U{additional_cooling_fan_speed[next_filament_id]/100.0} V{min(1.0,(additional_cooling_fan_speed[next_filament_id]+10)/100.0)} O70
{elsif (nozzle_diameter_at_nozzle_id[next_nozzle_id] <= 0.45)}
M142 P1 R45 S60 U{additional_cooling_fan_speed[next_filament_id]/100.0} V{min(1.0,(additional_cooling_fan_speed[next_filament_id]+10)/100.0)} O75
{else}
M142 P1 R48 S65 U{additional_cooling_fan_speed[next_filament_id]/100.0} V{min(1.0,(additional_cooling_fan_speed[next_filament_id]+10)/100.0)} O80
{endif}
{endif}

{endif}
{endif}
;not set fan changing filament
;not set fan changing filament

i use bambu studio as orca slicer added some fan setting not specified in the code above..

2 Likes