Static mesh - Phil1988/FreeDi GitHub Wiki

Default in this project is adaptive meshing (KAMP-style): it creates a bed mesh only for the area that is actually used by the current print job, instead of probing the full bed.

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 may only be relevant for you if you dont want to use an adaptive mesh

Why use 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 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: https://github.com/Phil1988/FreeDi/issues/347).

Usage (current state)

At the moment, using the static mesh is only possible from the printer display (LCD).
Steps: File Explorer → select print file → in the preview disable the KAMP toggle.

image

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 (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.
    image

  4. When prompted for a profile name, you must use: STATIC_MESH (this name is required so the macro can find it).
    image

  5. Wait until the meshing finishes. Then, click on SAVE CONFIG to store it to your printer.cfg. image



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: image

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


Slicer settings (Start G-code)

Open your slicer and inspect the Start G-code.

Example for reference on Orca Slicer:
image

Many slicers/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 removed/disabled for static-mesh usage.
  • Recommendation: comment it out instead of deleting it, e.g. prepend ; so you can restore it later.

Example (commented out):

; G29; mesh bed leveling ,comment this code to close it

OR

; 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: https://github.com/Phil1988/FreeDi/tree/master/config_section
Make sure to see the device specifig examples below.


Macro concept for STATIC_MESH:

Core macro: NEXT_PRINT_STATIC_MESH

Add this to your macros.cfg (if it does not exist 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 %}

Update your PRINT_START macro if needed

Your PRINT_START macro must have:

  1. A variable flag (variable_force_static_mesh)
  2. Logic to load STATIC_MESH when the flag is set, otherwise do normal adaptive meshing
1) Add the variable

Insert this after: description: Start printing
and before: gcode:

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

2) Read + reset the flag

Insert this after: 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 immediately for the next print after this one

3) Load STATIC_MESH (or fallback)

Insert this after the bed has been heated (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

GCODE (X-Smart3)
# 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-Plus3

GCODE (X-Plus3)
# 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

GCODE (X-Max3)
# 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

GCODE (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 


Plus4

GCODE (Plus4)
# 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 

⚠️ **GitHub.com Fallback** ⚠️