> For the complete documentation index, see [llms.txt](https://klipper.3dwork.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://klipper.3dwork.io/klipper/mejoras/macros-mejoras/mallado-de-cama-inteligente.md).

# Mallado de cama inteligente

{% hint style="warning" %}
IMPORTANTE!!!

En versiones de Klipper desde 26 de Enero de 2024 contamos con una nueva funcionalidad en el mallado de cama... el mallado adaptativo. Ya no necesitaremos macros o extensiones externas a Klipper para disponer de esta funcionalidad!!!

Podéis ver [**más información aquí**](/klipper/empezamos/malla-nivelacion-de-cama-klipper.md#bed-mesh-switchwire).
{% endhint %}

El mallado de nivelación de cama es un gran avance para corregir desviaciones en nuestra superficie de impresión pero en ocasiones se podría mejorar para que fuera más efectivo.

<figure><img src="/files/erdl4adV0WcCc5huPzF7" alt=""><figcaption></figcaption></figure>

Gracias a la versatilidad de Klipper podremos usar la siguiente macro que permitirá hacer un mallado de nuestra cama basada en el tamaño de la pieza que queramos imprimir, mejorando de esta forma el mallado y correcciones.

<figure><img src="/files/XkJyzazLlBdAOvDDBjKM" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/XV09vwzuCiW1WdblYTMs" alt=""><figcaption></figcaption></figure>

Además, este sistema nos permite:

* Reusar el mallado si el área de impresión es menor o igual que el anterior
* Tener en cuenta nuestros offsets del sensor
* Número de puntos por eje dinamico
* Compatible con sistemas de nivelación que usen sus propias macros como el Klicky

## Configuración

* Descargaremos e instalaremos la macro lanzando los siguientes comandos desde nuestro terminal SSH:

```bash
cd ~
git clone https://github.com/Turge08/print_area_bed_mesh.git
~/print_area_bed_mesh/install.sh
```

{% hint style="warning" %}
En el caso que usemos unos path/directorios diferentes a los normales es aconsejable revisar el script de instalación para adaptarlo a nuestras necesidades.
{% endhint %}

* Añadiremos esta macro en nuestro printer.cfg o cfg añadido como include que usemos para nuestras macros. Esta macro básicamente reemplazará a la macro BED\_MESH\_CALIBRATE usada por defecto

```django
[include print_area_bed_mesh.cfg]
```

* Añadiremos a nuestra configuración de Moonraker el update automático del repositorio para tener siempre actualizado de forma sencilla

{% code title="moonraker.conf" %}

```django
[update_manager print_area_bed_mesh]
type: git_repo
path: ~/print_area_bed_mesh
origin: https://github.com/Turge08/print_area_bed_mesh.git
is_system_service: False
```

{% endcode %}

{% hint style="warning" %}
Debemos asegurarnos que hemos realizado el primer paso antes o veremos un error en el apartado actualizaciones de nuestra UI.
{% endhint %}

Por último deberemos ajustar nuestro laminador y/o nuestra macro de inicio

* **Si usamos BED\_MESH\_CALIBRATE en nuestra macro de inicio** de impresión tendremos que reemplazar la llamada así:
  * ```
    BED_MESH_CALIBRATE PRINT_MIN={params.PRINT_MIN} PRINT_MAX={params.PRINT_MAX}
    ```
  * Si queremos forzar el mallado en cada impresión:
  * ```
    BED_MESH_CALIBRATE PRINT_MIN={params.PRINT_MIN} PRINT_MAX={params.PRINT_MAX} FORCE_NEW_MESH=True
    ```
  * Ajustaremos nuestro script de inicio de nuestro laminador

{% tabs %}
{% tab title="PrusaSlicer/SuperSlicer" %}
En el caso que actualmente usemos la macro START\_PRINT pasando temperaturas del estilo `START_PRINT BED_TEMP={material_bed_temperature_layer_0} EXTRUDER_TEMP={material_print_temperature_layer_0}.`

Tendremos que hacer algunos ajustes en la nueva macro y en START\_PRINT tal como vemos a continuación para adaptar el gcode de inicio con respecto a lo comentado inicialmente:

```gcode
START_PRINT EXTRUDER_TEMP={first_layer_temperature[initial_extruder] + extruder_temperature_offset[initial_extruder]} BED_TEMP=[first_layer_bed_temperature] CHAMBER=[chamber_temperature] PRINT_MIN={first_layer_print_min[0]},{first_layer_print_min[1]} PRINT_MAX={first_layer_print_max[0]},{first_layer_print_max[1]}
```

Con esta modificación desde START\_PRINT capturamos parámetros y llamamos a nuestra nueva macro de mallado.
{% endtab %}

{% tab title="IdeaMaker" %}

```
BED_MESH_CALIBRATE PRINT_MIN={print_pos_min_x},{print_pos_min_y} PRINT_MAX={print_pos_max_x},{print_pos_max_y}
```

{% endtab %}

{% tab title="Cura" %}

```
BED_MESH_CALIBRATE PRINT_MIN=%MINX%,%MINY% PRINT_MAX=%MAXX%,%MAXY%
```

{% hint style="info" %}
Deberemos de instalar el plugin [**Post Process Plugin (by frankbags)**](https://gist.github.com/frankbags/c85d37d9faff7bce67b6d18ec4e716ff) desde el menú ***Help/Show*** configuration Folder... copiaremos el script del link anterior dentro de la carpeta script.\
Reiniciamos Cura e iremos a ***Extensions/Post processing/Modify G-Code*** y seleccionaremos ***Mesh Print Size***.
{% endhint %}
{% endtab %}
{% endtabs %}

* **En el caso de que lancemos la macro** **BED\_MESH\_CALIBRATE directamente desde el gcode de inicio de nuestro laminador**

{% tabs %}
{% tab title="PrusaSlicer/SuperSlicer" %}

```
BED_MESH_CALIBRATE PRINT_MIN={first_layer_print_min[0]},{first_layer_print_min[1]} PRINT_MAX={first_layer_print_max[0]},{first_layer_print_max[1]}
```

{% endtab %}

{% tab title="IdeaMaker" %}

```
BED_MESH_CALIBRATE PRINT_MIN={print_pos_min_x},{print_pos_min_y} PRINT_MAX={print_pos_max_x},{print_pos_max_y}
```

{% endtab %}

{% tab title="Cura" %}

```
BED_MESH_CALIBRATE PRINT_MIN=%MINX%,%MINY% PRINT_MAX=%MAXX%,%MAXY%
```

{% endtab %}
{% endtabs %}

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://klipper.3dwork.io/klipper/mejoras/macros-mejoras/mallado-de-cama-inteligente.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
