Skip to content

Commit

Permalink
Update primeline so that it runs along the rectangle of the first layer
Browse files Browse the repository at this point in the history
Thanks to fbeauKmi

Co-Authored-By: Frédéric Beaucamp <[email protected]>
  • Loading branch information
elpopo-eng and fbeauKmi committed Feb 24, 2024
1 parent 405a98e commit da75f1d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
20 changes: 18 additions & 2 deletions macros/helpers/prime_line.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ gcode:
{% set prime_line_y = params.START_Y|default(prime_line_y)|float %}
{% set prime_line_direction = params.LINE_DIRECTION|default(printer["gcode_macro _USER_VARIABLES"].prime_line_direction)|string|upper %}

# Redefine start position from fl_size
{% set fl_size=printer['gcode_macro START_PRINT'].fl_size %}
{% if fl_size != "0_0_0_0" %}
{% set prime_line_margin = params.LINE_MARGIN|default(printer["gcode_macro _USER_VARIABLES"].prime_line_margin|float) %}
{% set min_x, min_y, max_x, max_y = fl_size.split("_")|map('float') %}
{% set prime_line_x = [[prime_line_x, min_x - prime_line_margin] | max, max_x + prime_line_margin] | min %}
{% set prime_line_y = [[prime_line_y, min_y - prime_line_margin] | max, max_y + prime_line_margin] | min %}
{% endif %}

{% set axes_max = printer.toolhead.axis_maximum %}
{% set prime_line_way = -1 if (prime_line_direction == "X" and prime_line_x > axes_max.x/2) or (prime_line_direction == "Y" and prime_line_y > axes_max.y/2) else 1 %}


{% if verbose %}
{action_respond_info("Prime line length: %.4f" % prime_line_length)}
{action_respond_info("Prime line eight: %.4f" % prime_line_height)}
Expand Down Expand Up @@ -92,10 +105,12 @@ gcode:

# Prime line
G92 E0

{% if prime_line_direction == "X" %}
G1 X{prime_line_x + prime_line_length} E{prime_line_purge_distance} F{speed}
G1 X{prime_line_x + prime_line_way*prime_line_length} E{prime_line_purge_distance} F{speed}
{% elif prime_line_direction == "Y" %}
G1 Y{prime_line_y + prime_line_length} E{prime_line_purge_distance} F{speed}
G1 Y{prime_line_y + prime_line_way*prime_line_length} E{prime_line_purge_distance} F{speed}

{% else %}
{ action_respond_error("Prime line direction is not valid. Choose either X or Y in the variables.cfg file!") }
{% endif %}
Expand All @@ -116,3 +131,4 @@ gcode:
{% if filament_sensor_enabled and re_enable_filament_sensor %}
SET_FILAMENT_SENSOR SENSOR="runout_sensor" ENABLE=1
{% endif %}

1 change: 1 addition & 0 deletions user_templates/variables.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ variable_prime_line_length: 40 # length of the prime line on the bed (in mm)
variable_prime_line_purge_distance: 30 # length of filament to purge (in mm)
variable_prime_line_flowrate: 10 # mm3/s used for the prime line
variable_prime_line_height: 0.6 # mm, used for actual cross section computation
variable_prime_line_margin: 5 # distance of purge line from fl_size rectangle

## Park position used when pause, end_print, etc...
variable_park_position_xy: -1, -1
Expand Down

0 comments on commit da75f1d

Please sign in to comment.