From a6ebee4e0951a825cb4e5ad7353d59337c9f225d Mon Sep 17 00:00:00 2001 From: Turge08 Date: Wed, 8 Dec 2021 21:44:18 -0500 Subject: [PATCH] Fixed issue where offset was causing "move out of range" error --- print_area_bed_mesh.cfg | 52 ++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/print_area_bed_mesh.cfg b/print_area_bed_mesh.cfg index a115a3f..99bfe6a 100644 --- a/print_area_bed_mesh.cfg +++ b/print_area_bed_mesh.cfg @@ -47,21 +47,21 @@ gcode: {% set OffsetY = probeConfig.y_offset|default(0)|float %} {% endif %} - {% set print_min_x = params.PRINT_MIN.split(",")[0] %} - {% set print_min_y = params.PRINT_MIN.split(",")[1] %} - {% set print_max_x = params.PRINT_MAX.split(",")[0] %} - {% set print_max_y = params.PRINT_MAX.split(",")[1] %} + {% set print_min_x = params.PRINT_MIN.split(",")[0]|float %} + {% set print_min_y = params.PRINT_MIN.split(",")[1]|float %} + {% set print_max_x = params.PRINT_MAX.split(",")[0]|float %} + {% set print_max_y = params.PRINT_MAX.split(",")[1]|float %} {% if last_area_start_x > 0 %} { action_respond_info("last_bed_mesh: %s,%s %s,%s" % (last_area_start_x, last_area_start_y, last_area_end_x, last_area_end_y)) } {% endif %} - {% if (params.FORCE_NEW_MESH != null) or (print_min_x|float < last_area_start_x|float) or (print_max_x|float > last_area_end_x|float) or (print_min_y|float < last_area_start_y|float) or (print_max_y|float > last_area_end_y|float) %} + {% if (params.FORCE_NEW_MESH != null) or (print_min_x < last_area_start_x) or (print_max_x > last_area_end_x) or (print_min_y < last_area_start_y) or (print_max_y > last_area_end_y) %} {% if klicky_available %} _CheckProbe action=query Attach_Probe {% endif %} - {% if (print_min_x|default(0)|float < print_max_x|default(0)|float) and (print_min_y|default(0)|float < print_max_y|default(0)|float) %} + {% if (print_min_x < print_max_x) and (print_min_y < print_max_y) %} # Get bed_mesh config (probe count, mesh_min and mesh_max for x and y {% set bedMeshConfig = printer['configfile'].config["bed_mesh"] %} @@ -77,35 +77,35 @@ gcode: {% set probe_count_y = probe_count_x|int %} {% endif %} {% set relative_reference_index = bedMeshConfig.relative_reference_index %} - {% set mesh_min_x = bedMeshConfig.mesh_min.split(",")[0]|int %} - {% set mesh_min_y = bedMeshConfig.mesh_min.split(",")[1]|int %} - {% set mesh_max_x = bedMeshConfig.mesh_max.split(",")[0]|int %} - {% set mesh_max_y = bedMeshConfig.mesh_max.split(",")[1]|int %} + {% set mesh_min_x = bedMeshConfig.mesh_min.split(",")[0]|float %} + {% set mesh_min_y = bedMeshConfig.mesh_min.split(",")[1]|float %} + {% set mesh_max_x = bedMeshConfig.mesh_max.split(",")[0]|float %} + {% set mesh_max_y = bedMeshConfig.mesh_max.split(",")[1]|float %} # If print area X is smaller than 50% of the bed size, change to to 3 probe counts for X instead of the default - {% if print_max_x|float - print_min_x|float < (mesh_max_x|float - mesh_min_x|float) * 0.50 %} + {% if print_max_x - print_min_x < (mesh_max_x - mesh_min_x) * 0.50 %} {% set probe_count_x = minimum_probe_count %} {% endif %} # If print area Y is smaller than 50% of the bed size, change to to 3 probe counts for Y instead of the default - {% if print_max_y|float - print_min_y|float < (mesh_max_y|float - mesh_min_y|float) * 0.50 %} + {% if print_max_y - print_min_y < (mesh_max_y - mesh_min_y) * 0.50 %} {% set probe_count_y = minimum_probe_count %} {% endif %} - {% if print_min_x|default(0)|float >= mesh_min_x %} - {% set mesh_min_x = print_min_x|default(0)|float - buffer %} + {% if print_min_x - buffer >= mesh_min_x %} + {% set mesh_min_x = print_min_x - buffer %} {% endif %} - {% if print_min_y|default(0)|float >= mesh_min_y %} - {% set mesh_min_y = print_min_y|default(0)|float - buffer %} + {% if print_min_y - buffer >= mesh_min_y %} + {% set mesh_min_y = print_min_y - buffer %} {% endif %} - {% if print_max_x|default(0)|float <= mesh_max_x %} - {% set mesh_max_x = print_max_x|default(0)|float + buffer %} + {% if print_max_x + buffer <= mesh_max_x %} + {% set mesh_max_x = print_max_x + buffer %} {% endif %} - {% if print_max_y|default(0)|float <= mesh_max_y %} - {% set mesh_max_y = print_max_y|default(0)|float + buffer %} + {% if print_max_y + buffer <= mesh_max_y %} + {% set mesh_max_y = print_max_y + buffer %} {% endif %} { action_respond_info("mesh_min: %s,%s" % (mesh_min_x, mesh_min_y)) } @@ -113,17 +113,17 @@ gcode: { action_respond_info("probe_count: %s,%s" % (probe_count_x,probe_count_y)) } ; Set variables so they're available outside of macro - SET_GCODE_VARIABLE MACRO=BED_MESH_CALIBRATE VARIABLE=last_area_start_x VALUE={print_min_x|float} - SET_GCODE_VARIABLE MACRO=BED_MESH_CALIBRATE VARIABLE=last_area_start_y VALUE={print_min_y|float} - SET_GCODE_VARIABLE MACRO=BED_MESH_CALIBRATE VARIABLE=last_area_end_x VALUE={print_max_x|float} - SET_GCODE_VARIABLE MACRO=BED_MESH_CALIBRATE VARIABLE=last_area_end_y VALUE={print_max_y|float} + SET_GCODE_VARIABLE MACRO=BED_MESH_CALIBRATE VARIABLE=last_area_start_x VALUE={print_min_x} + SET_GCODE_VARIABLE MACRO=BED_MESH_CALIBRATE VARIABLE=last_area_start_y VALUE={print_min_y} + SET_GCODE_VARIABLE MACRO=BED_MESH_CALIBRATE VARIABLE=last_area_end_x VALUE={print_max_x} + SET_GCODE_VARIABLE MACRO=BED_MESH_CALIBRATE VARIABLE=last_area_end_y VALUE={print_max_y} {% if (relative_reference_index == 0) %} - _BED_MESH_CALIBRATE mesh_min={mesh_min_x|float},{mesh_min_y|float} mesh_max={mesh_max_x|float},{mesh_max_y|float} probe_count={probe_count_x},{probe_count_y} + _BED_MESH_CALIBRATE mesh_min={mesh_min_x},{mesh_min_y} mesh_max={mesh_max_x},{mesh_max_y} probe_count={probe_count_x},{probe_count_y} {% else %} {% set relative_reference_index = ((probe_count_x * probe_count_y)-1)/2|int %} { action_respond_info("relative_reference_index: %s" % relative_reference_index|int) } - _BED_MESH_CALIBRATE mesh_min={mesh_min_x|float},{mesh_min_y|float} mesh_max={mesh_max_x|float},{mesh_max_y|float} probe_count={probe_count_x},{probe_count_y} relative_reference_index={relative_reference_index|int} + _BED_MESH_CALIBRATE mesh_min={mesh_min_x},{mesh_min_y} mesh_max={mesh_max_x},{mesh_max_y} probe_count={probe_count_x},{probe_count_y} relative_reference_index={relative_reference_index|int} {% endif %} {% else %} _BED_MESH_CALIBRATE