-
Notifications
You must be signed in to change notification settings - Fork 4
/
prime.cfg
75 lines (69 loc) · 4.48 KB
/
prime.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#
# Parametric PRIME LINE macro.
#
# Purges a set amounf of filament, then prints a nozzle priming line at the front of the bed.
# Calculates plastic flow and line size automatically based on nozzle diameter and bed size.
#
# Most of the apects of how it does things are configurable, see the "params.SOMETHING" lines in the code below.
# Full list of accepted parameters and their default values below. All of them are optional and do not have to be specified if you don't want the values changed:
#
# PRIME_LINE
# PRIME_LINE XPAD=0 YPAD=0 LENGTH=150 PRINT_SPEED=30 TRAVEL_SPEED=200 PURGE=8 RETRACT=1 EXTRUSION_MULTIPLIER=1.25 PRINT_HANDLE=1 HANDLE_FAN=35
#
# Careful: prints close to bed. Make sure your z-offset is correctly set and your bed mesh loaded, otherwise
# you can damage your print surface.
#
# Version 1.2
#
[gcode_macro PRIME_LINE]
description: Print an easy to remove parametric extruder priming line with a built-in handle.
gcode:
# settings
{% set line = {
'x_padding' : params.XPAD|default(0)|float, # left/right padding around the bed the line can't print into
'y_padding' : params.YPAD|default(0)|float, # top/bottom padding around the bed the line can't print into
'initial_purge' : params.PURGE|default(8)|int, # mm of filament to purge before printing. set to 0 to disable
'retract_after' : params.RETRACT|default(1)|int, # mm of filament to recract after printing. set to 0 to disable
'length' : params.LENGTH|default(150)|int,
'print_speed' : params.PRINT_SPEED|default(30)|int,
'travel_speed' : params.TRAVEL_SPEED|default(200)|int,
'extr_multi' : params.EXTRUSION_MULTIPLIER|default(1.25)|float, # apply to prime lines
'overlap_percent': 80, # how much prime lines overlap each other
} %}
{% set handle = {
'do_print' : params.PRINT_HANDLE|default(1)|int, # set to 0 to disable printing the handle
'fan_percent' : params.HANDLE_FAN|default(40)|int, # without fan the handle is too small and melty to print upright
'width' : 5.0,
'height' : 5.0,
'move_away' : 60 # how much to move the toolhead away from the printed handle once done. set 0 to disable
} %}
# sanity check and computed variables
{% set max_x, max_y, nozzle_diameter = printer.toolhead.axis_maximum.x|float, printer.toolhead.axis_maximum.y|float, printer.configfile.config['extruder'].nozzle_diameter|float %}
{% set _ = line.update({'width': nozzle_diameter * 1.25, 'height': nozzle_diameter / 2, 'length': [line.length, max_x - 2 * line.x_padding - 2]|min}) %}
{% set _ = line.update({'e_per_mm': line.extr_multi * (line.width * line.height) / (3.1415 * (1.75/2)**2), 'x_start': max_x / 2 - line.length / 2, 'y_start': line.y_padding + range(0,5)|random}) %}
SAVE_GCODE_STATE NAME=STATE_PRIME_LINE
M117 Prime Line
G90 # absolute positioning
G0 X{line.x_start} Y{line.y_start + (handle.width / 2)|int + 1} Z{line.height} F{line.travel_speed * 60} # move to starting position
G91 # relative positioning
G1 E{line.initial_purge} F{5 * 60} # extrude at ~12mm3/sec
G0 F{line.print_speed * 60} # set print speed
G1 X{line.length} E{line.length * line.e_per_mm} # print forward line
G0 Y{line.width * line.overlap_percent / 100} # overlap forward line
G1 X-{line.length / 2} E{(line.length / 2) * line.e_per_mm} # print backward line for half the length
# print a handle for easy removal
{% if handle.do_print != 0 and handle.width != 0 and handle.height != 0 %}
G0 X{line.length / 2 - handle.width} Y{handle.width / 2} F{line.travel_speed * 60} # move into position for printing handle
G0 F{line.print_speed * 60} # set print speed
{% set saved_fan_speed = (printer['fan'].speed * 256)|int %}
M106 S{((handle.fan_percent / 100) * 256)|int} # set part fan to desired speed
{% for _ in range((line.height * 1000)|int, (handle.height * 1000)|int, (line.height * 1000)|int) %} # loop however many cycles it takes to print required handle height
G1 Y{loop.cycle(-1.0, 1.0) * handle.width} E{handle.width * line.e_per_mm} # handle layer
G0 X-{line.width * 0.2} Z{line.height} # move up and shift the layer to make the handle sloping
{% endfor %}
M106 S{saved_fan_speed} # restore previous part fan speed
{% endif %}
G1 E-{line.retract_after} F{50 * 60} # retract ar 50mm/sec after printing
G0 Y{handle.move_away} F{line.travel_speed * 60}
M117
RESTORE_GCODE_STATE NAME=STATE_PRIME_LINE