diff --git a/printer_data/config/printer.cfg b/printer_data/config/printer.cfg index f75404c..e8f4cd3 100644 --- a/printer_data/config/printer.cfg +++ b/printer_data/config/printer.cfg @@ -672,7 +672,11 @@ gcode: SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=thermal_z_comp VALUE={thermal_z_comp} { action_respond_info("PRINT_START: hot-nozzle Z compensation +%.3f mm for %d C" % (thermal_z_comp, hotendtemp)) } STATUS_CLEANING - LINE_PURGE + {% if params.PRINT_MIN is defined and params.PRINT_MAX is defined %} + LINE_PURGE PRINT_MIN={params.PRINT_MIN} PRINT_MAX={params.PRINT_MAX} + {% else %} + LINE_PURGE + {% endif %} STATUS_PRINTING [gcode_macro TOUCH_SAVE_Z_OFFSET] @@ -714,16 +718,18 @@ gcode: [gcode_macro LINE_PURGE] description: Adaptive purge outside the print; safely skips when no free edge exists -# Object polygons from the slicer do not include brim or skirt. 15 mm covers the -# Orca profile (5 mm brim, skirt 2 mm away with up to 5 loops = ~9.5 mm) plus -# the squished purge line width. Override per job with CLEARANCE=. -variable_clearance: 15.0 +# Preferred bounds: PRINT_MIN/PRINT_MAX from Orca (first_layer_print_min/max), +# which already include brim and skirt, kept footprint_clearance away. +# Fallback: object polygons, which exclude brim and skirt; observed Orca jobs put +# the skirt up to ~12 mm outside them, so polygon_clearance is larger. +variable_footprint_clearance: 5.0 +variable_polygon_clearance: 15.0 gcode: {% set objects = printer.exclude_object.objects %} {% set points = objects | map(attribute='polygon') | sum(start=[]) %} + {% set use_footprint = params.PRINT_MIN is defined and params.PRINT_MAX is defined %} {% set line_length = 100.0 %} {% set wipe_length = 5.0 %} - {% set clearance = params.CLEARANCE|default(clearance)|float %} {% set x_offset = printer.configfile.settings.cartographer.x_offset|float %} {% set y_offset = printer.configfile.settings.cartographer.y_offset|float %} # Both nozzle and protruding Cartographer must remain at least 5 mm inside @@ -737,15 +743,26 @@ gcode: { action_raise_error("LINE_PURGE requires homed X, Y and Z") } {% elif not printer.extruder.can_extrude %} { action_raise_error("LINE_PURGE requires a hot extruder") } - {% elif points|length == 0 %} - { action_respond_info("LINE_PURGE skipped: slicer supplied no object polygons") } + {% elif not use_footprint and points|length == 0 %} + { action_respond_info("LINE_PURGE skipped: slicer supplied neither PRINT_MIN/PRINT_MAX nor object polygons") } {% elif safe_x_max - safe_x_min < line_length + wipe_length or safe_y_max - safe_y_min < line_length + wipe_length %} { action_respond_info("LINE_PURGE skipped: configured safe area is too small") } {% else %} - {% set object_x_min = points | map(attribute=0) | min | float %} - {% set object_x_max = points | map(attribute=0) | max | float %} - {% set object_y_min = points | map(attribute=1) | min | float %} - {% set object_y_max = points | map(attribute=1) | max | float %} + {% if use_footprint %} + {% set source = "first-layer footprint (brim/skirt included)" %} + {% set clearance = params.CLEARANCE|default(footprint_clearance)|float %} + {% set object_x_min = params.PRINT_MIN.split(',')[0]|float %} + {% set object_y_min = params.PRINT_MIN.split(',')[1]|float %} + {% set object_x_max = params.PRINT_MAX.split(',')[0]|float %} + {% set object_y_max = params.PRINT_MAX.split(',')[1]|float %} + {% else %} + {% set source = "object polygons (brim/skirt not included)" %} + {% set clearance = params.CLEARANCE|default(polygon_clearance)|float %} + {% set object_x_min = points | map(attribute=0) | min | float %} + {% set object_x_max = points | map(attribute=0) | max | float %} + {% set object_y_min = points | map(attribute=1) | min | float %} + {% set object_y_max = points | map(attribute=1) | max | float %} + {% endif %} {% set front_gap = object_y_min - safe_y_min %} {% set left_gap = object_x_min - safe_x_min %} {% set right_gap = safe_x_max - object_x_max %} @@ -791,7 +808,7 @@ gcode: {% endif %} G0 Z2 F600 RESTORE_GCODE_STATE NAME=LINE_PURGE_STATE MOVE=0 - { action_respond_info("LINE_PURGE used the %s free edge with %.1f mm object clearance" % (edge, clearance)) } + { action_respond_info("LINE_PURGE used the %s free edge, %.1f mm from the %s" % (edge, clearance, source)) } {% endif %} {% endif %}