Skip to content

Static Bed Mesh

The default bed mesh method in FreeDi is adaptive meshing (KAMP-style): it creates a bed mesh only for the area that is actually used by the current printing job, instead of probing the full bed surface.

Klipper v0.13 also introduced a native adaptive approach comparable to KAMP (so “adaptive meshing” is no longer strictly an external add-on concept).

Note

This is not mandatory. This section is relevant for you only if you don't want to use an adaptive mesh and use a static, saved mesh instead.

Why using a static mesh?

A static mesh can be useful if you want to start prints faster (“YOLO style” because the bed is not re-probed precisely before each job), or if you have general issues with your probe/sensor or adaptive meshing and want to compensate with one well-made mesh. This feature was requested as an option (see: issue #347) .

Usage

There are two ways to activate the static mesh for the next print:

  • Printer display (LCD)
    File Explorer → select print file → in the preview, disable the KAMP toggle.
  • NEXT_PRINT_STATIC_MESH macro
    Call it manually via the Mainsail console, or add it to your slicer's start G-code in a dedicated profile to apply it automatically.

Requirements & setup

Prerequisites

  • You need to have created a STATIC_MESH (see section “Create the STATIC_MESH” below)
  • You need a working macro setup (see section “Macros” below).
  • Your slicer must not force adaptive meshing every time (see “Slicer settings”).

Create the STATIC_MESH map in Mainsail

To create the mesh, 1. Open Mainsail → HEIGHTMAP. 2. Click the Home (house) icon to home the printer. 3. Click CALIBRATE to probe the mesh.

  1. When prompted for a profile name, you must use: STATIC_MESH (this name is required so the macro can find it).
  1. Wait until the meshing finishes. Then, click on SAVE CONFIG to store it to your printer.cfg.

After klipper restarted, you should be able to see the created STATIC_MESH on the right side. You can visualise it using the "load mesh" icon:

If you did a very poor job like I did for the purpose of this guide, you will see something like this:


Slicer Start G-code settings

Open your slicer and inspect the Start G-code.
Example for reference in Orca Slicer:

Many slicer's printer profiles automatically trigger bed leveling actions; we must ensure they do not always generate an adaptive mesh.

  • If you see something like G29, remove or disable it (printer-dependent).
  • If you see something like BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1, it will force adaptive probing via Klipper’s adaptive calibration parameter and should be disabled for static-mesh usage.

Recommendation: comment out the lines instead of deleting them, e.g. prepend ; in front of them so you can restore them later.

commented out exemples:

; G29; mesh bed leveling
; BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1

Macros

These are examples that were current at the time this wiki page was written, but they can change regularly.
The up-to-date configuration examples can always be found here: FreeDi configuration files

You can check and feel free to use the Device-specific examples.

Macro concept for using a static mesh

Adding the core macro: NEXT_PRINT_STATIC_MESH

Add this to your macros.cfg if it's not included yet. It sets a flag so the next print uses the stored STATIC_MESH profile instead of adaptive meshing:

# Flag macro to use STATIC_MESH usage instead of KAMP (needed make this function work from printjob selection on the LCD)
[gcode_macro NEXT_PRINT_STATIC_MESH]
description: Forces the NEXT print to use 'STATIC_MESH' instead of KAMP.
gcode:
    {% if "STATIC_MESH" in printer.bed_mesh.profiles %}
        SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=force_static_mesh VALUE=True
        {action_respond_info("The NEXT print will use 'STATIC_MESH'.")}
        M118 The NEXT print will use the STATIC_MESH.
    {% else %}
        {action_respond_info("WARNING: No mesh named 'STATIC_MESH' found. Please save one first (BED_MESH_PROFILE SAVE=STATIC_MESH).")}
        M118 WARNING: No mesh named STATIC_MESH found. Please save one first (BED_MESH_PROFILE SAVE=STATIC_MESH).
    {% endif %}

Updating your PRINT_START macro if needed

Your PRINT_START macro must have:

  • A variable flag (variable_force_static_mesh)
  • The logic to use a static mesh when the flag is set, otherwise using adaptive meshing

Add the variable to your macro:

Add the line variable_force_static_mesh: False in your PRINT_START macro like this:

[gcode_macro PRINT_START]
# Use PRINT_START for the slicer starting script
description: Start printing
variable_force_static_mesh: False         ; Set to True to force a static mesh instead of KAMP
gcode:

Add the "read + reset" flag:

Insert this right below SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=Mainboard_fan TARGET=1

{% set KAMP_deactivated = printer["gcode_macro PRINT_START"].force_static_mesh %}     ; Check if KAMP is deactivated for this print
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=force_static_mesh VALUE=False           ; Auto-reset the variable for the next print

Add the load STATIC_MESH or fallback logic

Insert this in your PRINT_START macro after the gcode lines starting the bed heating. The exact position depends on your PRINT_START flow:

{% if KAMP_deactivated %}
    {% if "STATIC_MESH" in printer.bed_mesh.profiles %}                                 ; Check if the spicific STATIC_MESH exists
        M118  Loading 'STATIC_MESH' instead of KAMP.
        BED_MESH_PROFILE LOAD=STATIC_MESH
    {% else %}                                                                          ; Fallback to KAMP if STATIC_MESH not found
        M118 ERROR: 'STATIC_MESH' not found! Using fallback: KAMP Adaptive Mesh.
        BED_MESH_CLEAR                                                                  ; Clear previous adaptive mesh
        BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1                                  ; Start adaptive meshing
    {% endif %}
{% else %}                                                                              ; Standard operation
    {% if printer.toolhead.homed_axes|length < 3 %}
        G28
    {% endif %}
    BED_MESH_CLEAR                                                                      ; Clear previous adaptive mesh
    BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1                                      ; Start adaptive meshing
{% endif %}

Device-specific examples

X-Smart3 macros

X-smart 3
# Flag macro to use STATIC_MESH usage instead of KAMP (needed make this function work from printjob selection on the LCD)
[gcode_macro NEXT_PRINT_STATIC_MESH]
description: Forces the NEXT print to use 'STATIC_MESH' instead of KAMP.
gcode:
    {% if "STATIC_MESH" in printer.bed_mesh.profiles %}
        SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=force_static_mesh VALUE=True
        {action_respond_info("The NEXT print will use 'STATIC_MESH'.")}
        M118 The NEXT print will use the STATIC_MESH.
    {% else %}
        {action_respond_info("WARNING: No mesh named 'STATIC_MESH' found. Please save one first (BED_MESH_PROFILE SAVE=STATIC_MESH).")}
        M118 WARNING: No mesh named STATIC_MESH found. Please save one first (BED_MESH_PROFILE SAVE=STATIC_MESH).
    {% endif %}


[gcode_macro PRINT_START]
# Use PRINT_START for the slicer starting script
description: Start printing
variable_force_static_mesh: False                                                                                 ; Set to True to force a static mesh instead of KAMP
gcode:
    {% set bed_target_temp = params.BED|default(0)|int %}
    {% set hotend_target_temp = params.HOTEND|default(0)|int %}

    {% set in_advanced_mode = (bed_target_temp > 0) or (hotend_target_temp > 0)%}

    CLEAR_PAUSE                                                                                                     ; Clear existing pause states
    BED_MESH_CLEAR                                                                                                  ; Clear previous adaptive mesh
    SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=Mainboard_fan TARGET=1                                               ; Decrease the mainboard target temp to fully turn the fan on

    {% set KAMP_deactivated = printer["gcode_macro PRINT_START"].force_static_mesh %}                               ; Check if KAMP is deactivated for this print
    SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=force_static_mesh VALUE=False                                     ; Auto-reset the variable immediately for the next print after this one 

    {% if in_advanced_mode %}
        {% set bed_center_x = printer.configfile.config["stepper_x"]["position_max"]|float / 2 %}
        {% set bed_center_y = printer.configfile.config["stepper_y"]["position_max"]|float / 2 %}

        {% set start_position_x = printer.toolhead.axis_maximum.x / 2 %}
        {% set start_position_y = printer.toolhead.axis_maximum.y - 40 %}
        {% set start_position_z = 10 %}

        M140 S{bed_target_temp}                                                                                      ; Set bed temperature
        G28                                                                                                          ; Home all axes

        G90                                                                                                          ; Set absolute positioning
        G1 X{start_position_x} Y{start_position_y} Z{start_position_z} F7800                                        ; Move to start position
        G28 Z                                                                                                        ; Home Z again for to compensate bed expansion     
    {% endif %}

    {% if KAMP_deactivated %}
        {% if "STATIC_MESH" in printer.bed_mesh.profiles %}                                                          ; Check if the spicific STATIC_MESH exists
            M118  Loading 'STATIC_MESH' instead of KAMP.
            BED_MESH_PROFILE LOAD=STATIC_MESH
        {% else %}                                                                                                   ; Fallback to KAMP if STATIC_MESH not found
            M118 ERROR: 'STATIC_MESH' not found! Using fallback: KAMP Adaptive Mesh.
            BED_MESH_CLEAR                                                                                           ; Clear previous adaptive mesh
            BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1                                                           ; Start adaptive meshing
        {% endif %}
    {% else %}                                                                                                       ; Standard operation
        {% if printer.toolhead.homed_axes|length < 3 %}
            G28
        {% endif %}
        BED_MESH_CLEAR                                                                                               ; Clear previous adaptive mesh
        BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1                                                               ; Start adaptive meshing
    {% endif %}

    {% if in_advanced_mode %}
       M109 S{hotend_target_temp}                                                                                  ; Set and wait for hotend temperature 
    {% endif %}

X-Plus 3 macros

X-Plus 3
# Flag macro to use STATIC_MESH usage instead of KAMP (needed make this function work from printjob selection on the LCD)
[gcode_macro NEXT_PRINT_STATIC_MESH]
description: Forces the NEXT print to use 'STATIC_MESH' instead of KAMP.
gcode:
    {% if "STATIC_MESH" in printer.bed_mesh.profiles %}
        SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=force_static_mesh VALUE=True
        {action_respond_info("The NEXT print will use 'STATIC_MESH'.")}
        M118 The NEXT print will use the STATIC_MESH.
    {% else %}
        {action_respond_info("WARNING: No mesh named 'STATIC_MESH' found. Please save one first (BED_MESH_PROFILE SAVE=STATIC_MESH).")}
        M118 WARNING: No mesh named STATIC_MESH found. Please save one first (BED_MESH_PROFILE SAVE=STATIC_MESH).
    {% endif %}


[gcode_macro PRINT_START]
# Use PRINT_START for the slicer starting script
description: Start printing
variable_force_static_mesh: False                                                                                 ; Set to True to force a static mesh instead of KAMP
gcode:
    {% set bed_target_temp = params.BED|default(0)|int %}
    {% set hotend_target_temp = params.HOTEND|default(0)|int %}
    {% set chamber_target_temp = params.CHAMBER|default(0)|int %}

    {% set in_advanced_mode = (bed_target_temp > 0) or (hotend_target_temp > 0) or (chamber_target_temp > 0) %}

    CLEAR_PAUSE                                                                                                     ; Clear existing pause states
    BED_MESH_CLEAR                                                                                                  ; Clear previous adaptive mesh
    SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=Mainboard_fan TARGET=1                                               ; Decrease the mainboard target temp to fully turn the fan on

    {% set KAMP_deactivated = printer["gcode_macro PRINT_START"].force_static_mesh %}                               ; Check if KAMP is deactivated for this print
    SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=force_static_mesh VALUE=False                                     ; Auto-reset the variable immediately for the next print after this one 

    {% if in_advanced_mode %}
        {% set bed_center_x = printer.configfile.config["stepper_x"]["position_max"]|float / 2 %}
        {% set bed_center_y = printer.configfile.config["stepper_y"]["position_max"]|float / 2 %}

        {% set start_position_x = printer.toolhead.axis_maximum.x / 2 %}
        {% set start_position_y = printer.toolhead.axis_maximum.y - 40 %}
        {% set start_position_z = 10 %}

        M140 S{bed_target_temp}                                                                                      ; Set bed temperature
        M141 S{chamber_target_temp}                                                                                  ; Set chamber temperature
        G28                                                                                                          ; Home all axes

        {% if chamber_target_temp > 0 %}                                                                             ; Accelerate chamber heating by using the bed as additional heater    
            G0 X{bed_center_x} Y{bed_center_y} Z3 F780                                                               ; Move print bed to perfect postion to help chamber heating
            M106 P2 S185                                                                                             ; Turn sidefan on to use bed heat and mix air
            M106 P0 S128                                                                                             ; Turn part cooling fan on to help air mixing
            TEMPERATURE_WAIT SENSOR="heater_generic chamber" MINIMUM={chamber_target_temp - 5}                       ; Wait for chamber to heat up
            M106 P2 S0                                                                                               ; Turn off sidefan
            M106 P0 S0                                                                                               ; Turn off part cooling fan                                                                      
        {% endif %}

        M191 S{chamber_target_temp}                                                                                  ; Set and wait for chamber temperature
        M190 S{bed_target_temp}                                                                                      ; Set and wait for bed temperature  
        G90                                                                                                          ; Set absolute positioning
        G1 X{start_position_x} Y{start_position_y} Z{start_position_z} F7800                                        ; Move to start position
        G28 Z                                                                                                        ; Home Z again for to compensate bed expansion     
    {% endif %}

    {% if KAMP_deactivated %}
        {% if "STATIC_MESH" in printer.bed_mesh.profiles %}                                                          ; Check if the spicific STATIC_MESH exists
            M118  Loading 'STATIC_MESH' instead of KAMP.
            BED_MESH_PROFILE LOAD=STATIC_MESH
        {% else %}                                                                                                   ; Fallback to KAMP if STATIC_MESH not found
            M118 ERROR: 'STATIC_MESH' not found! Using fallback: KAMP Adaptive Mesh.
            BED_MESH_CLEAR                                                                                           ; Clear previous adaptive mesh
            BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1                                                           ; Start adaptive meshing
        {% endif %}
    {% else %}                                                                                                       ; Standard operation
        {% if printer.toolhead.homed_axes|length < 3 %}
            G28
        {% endif %}
        BED_MESH_CLEAR                                                                                               ; Clear previous adaptive mesh
        BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1                                                               ; Start adaptive meshing
    {% endif %}

    {% if in_advanced_mode %}
       M109 S{hotend_target_temp}                                                                                  ; Set and wait for hotend temperature 
    {% endif %}

X-max3 macros

X-max 3
# Flag macro to use STATIC_MESH usage instead of KAMP (needed make this function work from printjob selection on the LCD)
[gcode_macro NEXT_PRINT_STATIC_MESH]
description: Forces the NEXT print to use 'STATIC_MESH' instead of KAMP.
gcode:
    {% if "STATIC_MESH" in printer.bed_mesh.profiles %}
        SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=force_static_mesh VALUE=True
        {action_respond_info("The NEXT print will use 'STATIC_MESH'.")}
        M118 The NEXT print will use the STATIC_MESH.
    {% else %}
        {action_respond_info("WARNING: No mesh named 'STATIC_MESH' found. Please save one first (BED_MESH_PROFILE SAVE=STATIC_MESH).")}
        M118 WARNING: No mesh named STATIC_MESH found. Please save one first (BED_MESH_PROFILE SAVE=STATIC_MESH).
    {% endif %}


[gcode_macro PRINT_START]
# Use PRINT_START for the slicer starting script
description: Start printing
variable_force_static_mesh: False                                                                                 ; Set to True to force a static mesh instead of KAMP
gcode:
    {% set bed_target_temp = params.BED|default(0)|int %}
    {% set hotend_target_temp = params.HOTEND|default(0)|int %}
    {% set chamber_target_temp = params.CHAMBER|default(0)|int %}

    {% set in_advanced_mode = (bed_target_temp > 0) or (hotend_target_temp > 0) or (chamber_target_temp > 0) %}

    CLEAR_PAUSE                                                                                                     ; Clear existing pause states
    BED_MESH_CLEAR                                                                                                  ; Clear previous adaptive mesh
    SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=Mainboard_fan TARGET=1                                               ; Decrease the mainboard target temp to fully turn the fan on

    {% set KAMP_deactivated = printer["gcode_macro PRINT_START"].force_static_mesh %}                               ; Check if KAMP is deactivated for this print
    SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=force_static_mesh VALUE=False                                     ; Auto-reset the variable immediately for the next print after this one 

    {% if in_advanced_mode %}
        {% set bed_center_x = printer.configfile.config["stepper_x"]["position_max"]|float / 2 %}
        {% set bed_center_y = printer.configfile.config["stepper_y"]["position_max"]|float / 2 %}

        {% set start_position_x = printer.toolhead.axis_maximum.x / 2 %}
        {% set start_position_y = printer.toolhead.axis_maximum.y - 40 %}
        {% set start_position_z = 10 %}

        M140 S{bed_target_temp}                                                                                      ; Set bed temperature
        M141 S{chamber_target_temp}                                                                                  ; Set chamber temperature
        G28                                                                                                          ; Home all axes

        {% if chamber_target_temp > 0 %}                                                                             ; Accelerate chamber heating by using the bed as additional heater    
            G0 X{bed_center_x} Y{bed_center_y} Z3 F780                                                               ; Move print bed to perfect postion to help chamber heating
            M106 P2 S185                                                                                             ; Turn sidefan on to use bed heat and mix air
            M106 P0 S128                                                                                             ; Turn part cooling fan on to help air mixing
            TEMPERATURE_WAIT SENSOR="heater_generic chamber" MINIMUM={chamber_target_temp - 5}                       ; Wait for chamber to heat up
            M106 P2 S0                                                                                               ; Turn off sidefan
            M106 P0 S0                                                                                               ; Turn off part cooling fan                                                                      
        {% endif %}

        M191 S{chamber_target_temp}                                                                                  ; Set and wait for chamber temperature
        M190 S{bed_target_temp}                                                                                      ; Set and wait for bed temperature  
        G90                                                                                                          ; Set absolute positioning
        G1 X{start_position_x} Y{start_position_y} Z{start_position_z} F7800                                        ; Move to start position
        G28 Z                                                                                                        ; Home Z again for to compensate bed expansion     
    {% endif %}

    {% if KAMP_deactivated %}
        {% if "STATIC_MESH" in printer.bed_mesh.profiles %}                                                          ; Check if the spicific STATIC_MESH exists
            M118  Loading 'STATIC_MESH' instead of KAMP.
            BED_MESH_PROFILE LOAD=STATIC_MESH
        {% else %}                                                                                                   ; Fallback to KAMP if STATIC_MESH not found
            M118 ERROR: 'STATIC_MESH' not found! Using fallback: KAMP Adaptive Mesh.
            BED_MESH_CLEAR                                                                                           ; Clear previous adaptive mesh
            BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1                                                           ; Start adaptive meshing
        {% endif %}
    {% else %}                                                                                                       ; Standard operation
        {% if printer.toolhead.homed_axes|length < 3 %}
            G28
        {% endif %}
        BED_MESH_CLEAR                                                                                               ; Clear previous adaptive mesh
        BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1                                                               ; Start adaptive meshing
    {% endif %}

    {% if in_advanced_mode %}
       M109 S{hotend_target_temp}                                                                                  ; Set and wait for hotend temperature 
    {% endif %}

Q1 Pro macros

Q1 pro
# Flag macro to use STATIC_MESH usage instead of KAMP (needed make this function work from printjob selection on the LCD)
[gcode_macro NEXT_PRINT_STATIC_MESH]
description: Forces the NEXT print to use 'STATIC_MESH' instead of KAMP.
gcode:
    {% if "STATIC_MESH" in printer.bed_mesh.profiles %}
        SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=force_static_mesh VALUE=True
        {action_respond_info("The NEXT print will use 'STATIC_MESH'.")}
        M118 The NEXT print will use the STATIC_MESH.
    {% else %}
        {action_respond_info("WARNING: No mesh named 'STATIC_MESH' found. Please save one first (BED_MESH_PROFILE SAVE=STATIC_MESH).")}
        M118 WARNING: No mesh named STATIC_MESH found. Please save one first (BED_MESH_PROFILE SAVE=STATIC_MESH).
    {% endif %}


[gcode_macro PRINT_START]
# Use PRINT_START for the slicer starting script
description: Start printing
variable_force_static_mesh: False                                                                                 ; Set to True to force a static mesh instead of KAMP
gcode:
    {% set bed_target_temp = params.BED|int %}
    {% set hotend_target_temp = params.HOTEND|int %}
    {% set chamber_target_temp = params.CHAMBER|default(0)|int %}
    {% set bed_center_x = printer.configfile.config["stepper_x"]["position_max"]|float / 2 %}
    {% set bed_center_y = printer.configfile.config["stepper_y"]["position_max"]|float / 2 %}

    {% set start_position_x = printer.toolhead.axis_maximum.x / 2 %}
    {% set start_position_y = printer.toolhead.axis_maximum.y - 40 %}
    {% set start_position_z = 10 %}

    CLEAR_PAUSE                                                                                                     ; Clear existing pause states
    BED_MESH_CLEAR                                                                                                  ; Clear previous adaptive mesh
    SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=Mainboard_fan TARGET=1                                               ; Decrease the mainboard target temp to fully turn the fan on

    {% set KAMP_deactivated = printer["gcode_macro PRINT_START"].force_static_mesh %}                               ; Check if KAMP is deactivated for this print
    SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=force_static_mesh VALUE=False                                     ; Auto-reset the variable immediately for the next print after this one 

    M140 S{bed_target_temp}
    M141 S{chamber_target_temp}
    G28

    {% if chamber_target_temp > 0 %}                                                                               ; Accelerate chamber heating by using the bed as additional heater    
        G0 X{bed_center_x} Y{bed_center_y} Z3 F780                                                                 ; Move print bed to perfect postion to help chamber heating
        M106 P2 S185                                                                                               ; Turn sidefan on to use bed heat and mix air
        M106 P0 S128                                                                                               ; Turn part cooling fan on to help air mixing
        TEMPERATURE_WAIT SENSOR="heater_generic chamber" MINIMUM={chamber_target_temp - 5}                         ; Wait for chamber to heat up
        M106 P2 S0                                                                                                 ; Turn off sidefan
        M106 P0 S0                                                                                                 ; Turn off part cooling fan                                      
    {% endif %}

    {% if bed_target_temp !=0 %}
      TEMPERATURE_WAIT SENSOR=heater_bed MINIMUM={bed_target_temp * 0.95} MAXIMUM={bed_target_temp * 1.05}
    {% endif %}

    M191 S{chamber_target_temp}                                                                                    ; Set and wait for chamber temperature
    M190 S{bed_target_temp}                                                                                        ; Set and wait for bed temperature 
    G90                                                                                                            ; Set absolute positioning
    G1 X{start_position_x} Y{start_position_y} Z{start_position_z} F7800                                           ; Move to start position
    G28 Z                                                                                                          ; Home Z again for to compensate bed expansion  

    {% if KAMP_deactivated %}
        {% if "STATIC_MESH" in printer.bed_mesh.profiles %}                                                        ; Check if the spicific STATIC_MESH exists
            M118  Loading 'STATIC_MESH' instead of KAMP.
            BED_MESH_PROFILE LOAD=STATIC_MESH
        {% else %}                                                                                                 ; Fallback to KAMP if STATIC_MESH not found
            M118 ERROR: 'STATIC_MESH' not found! Using fallback: KAMP Adaptive Mesh.
            BED_MESH_CLEAR                                                                                         ; Clear previous adaptive mesh
            BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1                                                         ; Start adaptive meshing
        {% endif %}
    {% else %}                                                                                                     ; Standard operation
        {% if printer.toolhead.homed_axes|length < 3 %}
            G28
        {% endif %}
        BED_MESH_CLEAR                                                                                             ; Clear previous adaptive mesh
        BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1                                                             ; Start adaptive meshing
    {% endif %}

    PRIME_NOZZLE hotend_target_temp={hotend_target_temp}
    M109 S{hotend_target_temp}                                                                                     ; Set and wait for hotend temperature 

Plus 4 macros

Plus 4
# Flag macro to use STATIC_MESH usage instead of KAMP (needed make this function work from printjob selection on the LCD)
[gcode_macro NEXT_PRINT_STATIC_MESH]
description: Forces the NEXT print to use 'STATIC_MESH' instead of KAMP.
gcode:
    {% if "STATIC_MESH" in printer.bed_mesh.profiles %}
        SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=force_static_mesh VALUE=True
        {action_respond_info("The NEXT print will use 'STATIC_MESH'.")}
        M118 The NEXT print will use the STATIC_MESH.
    {% else %}
        {action_respond_info("WARNING: No mesh named 'STATIC_MESH' found. Please save one first (BED_MESH_PROFILE SAVE=STATIC_MESH).")}
        M118 WARNING: No mesh named STATIC_MESH found. Please save one first (BED_MESH_PROFILE SAVE=STATIC_MESH).
    {% endif %}


[gcode_macro PRINT_START]
# Use PRINT_START for the slicer starting script
description: Start printing
variable_force_static_mesh: False                                                                                 ; Set to True to force a static mesh instead of KAMP
gcode:
    {% set bed_target_temp = params.BED|int %}
    {% set hotend_target_temp = params.HOTEND|int %}
    {% set chamber_target_temp = params.CHAMBER|default(0)|int %}
    {% set bed_center_x = printer.configfile.config["stepper_x"]["position_max"]|float / 2 %}
    {% set bed_center_y = printer.configfile.config["stepper_y"]["position_max"]|float / 2 %}

    {% set start_position_x = printer.toolhead.axis_maximum.x / 2 %}
    {% set start_position_y = printer.toolhead.axis_maximum.y - 40 %}
    {% set start_position_z = 10 %}

    CLEAR_PAUSE                                                                                                     ; Clear existing pause states
    BED_MESH_CLEAR                                                                                                  ; Clear previous adaptive mesh
    SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=Mainboard_fan TARGET=1                                               ; Decrease the mainboard target temp to fully turn the fan on

    {% set KAMP_deactivated = printer["gcode_macro PRINT_START"].force_static_mesh %}                               ; Check if KAMP is deactivated for this print
    SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=force_static_mesh VALUE=False                                     ; Auto-reset the variable immediately for the next print after this one 

    M140 S{bed_target_temp}
    M141 S{chamber_target_temp}
    G28

    {% if chamber_target_temp > 0 %}                                                                               ; Accelerate chamber heating by using the bed as additional heater    
        G0 X{bed_center_x} Y{bed_center_y} Z3 F780                                                                 ; Move print bed to perfect postion to help chamber heating
        M106 P2 S185                                                                                               ; Turn sidefan on to use bed heat and mix air
        M106 P0 S128                                                                                               ; Turn part cooling fan on to help air mixing
        TEMPERATURE_WAIT SENSOR="heater_generic chamber" MINIMUM={chamber_target_temp - 5}                         ; Wait for chamber to heat up
        M106 P2 S0                                                                                                 ; Turn off sidefan
        M106 P0 S0                                                                                                 ; Turn off part cooling fan                                      
    {% endif %}

    {% if bed_target_temp !=0 %}
      TEMPERATURE_WAIT SENSOR=heater_bed MINIMUM={bed_target_temp * 0.95} MAXIMUM={bed_target_temp * 1.05}
    {% endif %}

    M191 S{chamber_target_temp}                                                                                    ; Set and wait for chamber temperature
    M190 S{bed_target_temp}                                                                                        ; Set and wait for bed temperature 
    G90                                                                                                            ; Set absolute positioning
    G1 X{start_position_x} Y{start_position_y} Z{start_position_z} F7800                                           ; Move to start position
    G28 Z                                                                                                          ; Home Z again for to compensate bed expansion  

    {% if KAMP_deactivated %}
        {% if "STATIC_MESH" in printer.bed_mesh.profiles %}                                                        ; Check if the spicific STATIC_MESH exists
            M118  Loading 'STATIC_MESH' instead of KAMP.
            BED_MESH_PROFILE LOAD=STATIC_MESH
        {% else %}                                                                                                 ; Fallback to KAMP if STATIC_MESH not found
            M118 ERROR: 'STATIC_MESH' not found! Using fallback: KAMP Adaptive Mesh.
            BED_MESH_CLEAR                                                                                         ; Clear previous adaptive mesh
            BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1                                                         ; Start adaptive meshing
        {% endif %}
    {% else %}                                                                                                     ; Standard operation
        {% if printer.toolhead.homed_axes|length < 3 %}
            G28
        {% endif %}
        BED_MESH_CLEAR                                                                                             ; Clear previous adaptive mesh
        BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1                                                             ; Start adaptive meshing
    {% endif %}

    PRIME_NOZZLE hotend_target_temp={hotend_target_temp}
    M109 S{hotend_target_temp}                                                                                     ; Set and wait for hotend temperature