mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Update PurgeLinesAndUnload.py
Updated with the combined changes and ready for review.
This commit is contained in:
parent
1859b9d12e
commit
f08873fa35
1 changed files with 458 additions and 434 deletions
|
@ -1,4 +1,4 @@
|
||||||
# August 2024 - GregValiant (Greg Foresi)
|
# August 2024 - Designed by: GregValiant (Greg Foresi). Straightened out by: Hellaholic
|
||||||
#
|
#
|
||||||
# NOTE: You may have purge lines in your startup, or you may use this script, you should not do both. The script will attempt to comment out existing StartUp purge lines.
|
# NOTE: You may have purge lines in your startup, or you may use this script, you should not do both. The script will attempt to comment out existing StartUp purge lines.
|
||||||
# 'Add Purge Lines to StartUp' Allows the user to determine where the purge lines are on the build plate, or to not use purge lines if a print extends to the limits of the build surface.
|
# 'Add Purge Lines to StartUp' Allows the user to determine where the purge lines are on the build plate, or to not use purge lines if a print extends to the limits of the build surface.
|
||||||
|
@ -10,32 +10,72 @@
|
||||||
# Added extra moves to account for Cura adding a "Travel to Prime Tower" move that can cross the middle of the build surface.
|
# Added extra moves to account for Cura adding a "Travel to Prime Tower" move that can cross the middle of the build surface.
|
||||||
# Added ability to take 'disallowed areas' into account.
|
# Added ability to take 'disallowed areas' into account.
|
||||||
|
|
||||||
|
import math
|
||||||
from ..Script import Script
|
from ..Script import Script
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
from UM.Message import Message
|
from UM.Message import Message
|
||||||
import re
|
import re
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
|
class Location(str, Enum):
|
||||||
|
LEFT = "left"
|
||||||
|
RIGHT = "right"
|
||||||
|
TOP = "top"
|
||||||
|
BOTTOM = "bottom"
|
||||||
|
REAR = "rear"
|
||||||
|
FRONT = "front"
|
||||||
|
|
||||||
|
|
||||||
|
class Position(tuple, Enum):
|
||||||
|
LEFT_FRONT = ("left", "front")
|
||||||
|
RIGHT_FRONT = ("right", "front")
|
||||||
|
LEFT_REAR = ("left", "rear")
|
||||||
|
RIGHT_REAR = ("right", "rear")
|
||||||
|
|
||||||
|
|
||||||
class PurgeLinesAndUnload(Script):
|
class PurgeLinesAndUnload(Script):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.curaApp = Application.getInstance().getGlobalContainerStack()
|
||||||
|
self.extruder = self.curaApp.extruderList
|
||||||
|
self.end_purge_location = None
|
||||||
|
self.speed_travel = None
|
||||||
|
# This will be True when there are more than 4 'machine_disallowed_areas'
|
||||||
|
self.show_warning = False
|
||||||
|
self.disallowed_areas = self.curaApp.getProperty("machine_disallowed_areas", "value")
|
||||||
|
self.extruder = self.curaApp.extruderList
|
||||||
|
self.extruder_count = self.curaApp.getProperty("machine_extruder_count", "value")
|
||||||
|
self.bed_shape = self.curaApp.getProperty("machine_shape", "value")
|
||||||
|
self.origin_at_center = self.curaApp.getProperty("machine_center_is_zero", "value")
|
||||||
|
self.machine_width = self.curaApp.getProperty("machine_width", "value")
|
||||||
|
self.machine_depth = self.curaApp.getProperty("machine_depth", "value")
|
||||||
|
self.machine_left = 1.0
|
||||||
|
self.machine_right = self.machine_width - 1.0
|
||||||
|
self.machine_front = 1.0
|
||||||
|
self.machine_back = self.machine_depth - 1.0
|
||||||
|
|
||||||
def initialize(self) -> None:
|
def initialize(self) -> None:
|
||||||
super().initialize()
|
super().initialize()
|
||||||
# Get the StartUp Gcode from Cura and attempt to catch if it contains purge lines. Message the user if an extrusion is in the startup.
|
# Get the StartUp Gcode from Cura and attempt to catch if it contains purge lines. Message the user if an extrusion is in the startup.
|
||||||
self.curaApp = Application.getInstance().getGlobalContainerStack()
|
|
||||||
startup_gcode = self.curaApp.getProperty("machine_start_gcode", "value")
|
startup_gcode = self.curaApp.getProperty("machine_start_gcode", "value")
|
||||||
start_lines = startup_gcode.splitlines()
|
start_lines = startup_gcode.splitlines()
|
||||||
for line in start_lines:
|
for line in start_lines:
|
||||||
if "G1" in line and " E" in line and (" X" in line or " Y" in line):
|
if "G1" in line and " E" in line and (" X" in line or " Y" in line):
|
||||||
Message(title = "[Purge Lines and Unload]", text = "It appears that there are 'purge lines' in the StartUp Gcode. Using the 'Add Purge Lines' function of this script will comment them out.").show()
|
Message(title="[Purge Lines and Unload]",
|
||||||
|
text="It appears that there are 'purge lines' in the StartUp Gcode. Using the 'Add Purge Lines' function of this script will comment them out.").show()
|
||||||
break
|
break
|
||||||
# 'is rectangular' is used to disable half-length purge lines for elliptic beds.
|
# 'is_rectangular' is used to disable half-length purge lines for elliptic beds.
|
||||||
self._instance.setProperty("is_rectangular", "value", True if self.curaApp.getProperty("machine_shape", "value") == "rectangular" else False)
|
self._instance.setProperty("is_rectangular", "value",
|
||||||
self._instance.setProperty("move_to_prime_tower", "value", True if self.curaApp.getProperty("machine_extruder_count", "value") > 1 else False)
|
True if self.curaApp.getProperty("machine_shape",
|
||||||
self.extruder = self.curaApp.extruderList
|
"value") == "rectangular" else False)
|
||||||
#This is set in 'Add Purge Lines' and is used by 'Move to Start' to indicate which corner the nozzle is in after the purge lines
|
self._instance.setProperty("move_to_prime_tower", "value",
|
||||||
self.start_location = "LF"
|
True if self.curaApp.getProperty("machine_extruder_count", "value") > 1 else False)
|
||||||
# Set the default E adjustment
|
# Set the default E adjustment
|
||||||
self._instance.setProperty("adjust_e_loc_to", "value", -abs(round(float(self.extruder[0].getProperty("retraction_amount", "value")), 1)))
|
self._instance.setProperty("adjust_e_loc_to", "value",
|
||||||
|
-abs(round(float(self.extruder[0].getProperty("retraction_amount", "value")), 1)))
|
||||||
|
|
||||||
def getSettingDataString(self):
|
def getSettingDataString(self):
|
||||||
return """{
|
return """{
|
||||||
|
@ -60,11 +100,11 @@ class PurgeLinesAndUnload(Script):
|
||||||
"description": "What edge of the build plate should have the purge lines. If the printer is 'Elliptical' then it is assumed to be an 'Origin At Center' printer and the purge lines are 90° arcs.",
|
"description": "What edge of the build plate should have the purge lines. If the printer is 'Elliptical' then it is assumed to be an 'Origin At Center' printer and the purge lines are 90° arcs.",
|
||||||
"type": "enum",
|
"type": "enum",
|
||||||
"options": {
|
"options": {
|
||||||
"purge_left": "On left edge (Xmin)",
|
"left": "On left edge (Xmin)",
|
||||||
"purge_right": "On right edge (Xmax)",
|
"right": "On right edge (Xmax)",
|
||||||
"purge_bottom": "On front edge (Ymin)",
|
"bottom": "On front edge (Ymin)",
|
||||||
"purge_top": "On back edge (Ymax)"},
|
"top": "On back edge (Ymax)"},
|
||||||
"default_value": "purge_left",
|
"default_value": "left",
|
||||||
"enabled": "add_purge_lines"
|
"enabled": "add_purge_lines"
|
||||||
},
|
},
|
||||||
"purge_line_length":
|
"purge_line_length":
|
||||||
|
@ -158,26 +198,13 @@ class PurgeLinesAndUnload(Script):
|
||||||
elif "PurgeLinesAndUnload" in line:
|
elif "PurgeLinesAndUnload" in line:
|
||||||
Logger.log("i", "[Add Purge Lines and Unload Filament] has already run on this gcode.")
|
Logger.log("i", "[Add Purge Lines and Unload Filament] has already run on this gcode.")
|
||||||
return data
|
return data
|
||||||
# This will be True when there are more than 4 'machine_disallowed_areas'
|
|
||||||
self.show_warning = False
|
|
||||||
self.disallowed_areas = self.curaApp.getProperty("machine_disallowed_areas", "value")
|
|
||||||
self.extruder = self.curaApp.extruderList
|
|
||||||
self.extruder_count = self.curaApp.getProperty("machine_extruder_count", "value")
|
|
||||||
self.bed_shape = self.curaApp.getProperty("machine_shape", "value")
|
|
||||||
self.origin_at_center = self.curaApp.getProperty("machine_center_is_zero", "value")
|
|
||||||
self.machine_width = self.curaApp.getProperty("machine_width", "value")
|
|
||||||
self.machine_depth = self.curaApp.getProperty("machine_depth", "value")
|
|
||||||
self.machine_left = 1.0
|
|
||||||
self.machine_right = self.machine_width - 1.0
|
|
||||||
self.machine_front = 1.0
|
|
||||||
self.machine_back = self.machine_depth - 1.0
|
|
||||||
# Adjust the usable size of the bed per any 'disallowed areas'
|
# Adjust the usable size of the bed per any 'disallowed areas'
|
||||||
max_print_size = self._get_build_plate_extents()
|
self._get_build_plate_extents()
|
||||||
self.speed_travel = self.extruder[0].getProperty("speed_travel", "value") * 60
|
self.speed_travel = self.extruder[0].getProperty("speed_travel", "value") * 60
|
||||||
# The start location changes according to which quadrant the nozzle is in at the beginning
|
# The start location changes according to which quadrant the nozzle is in at the beginning
|
||||||
self.start_location = self._get_real_start_point(data[1])
|
self.end_purge_location = self._get_real_start_point(data[1])
|
||||||
|
|
||||||
# Run the selected procedures
|
|
||||||
# Mapping settings to corresponding methods
|
# Mapping settings to corresponding methods
|
||||||
procedures = {
|
procedures = {
|
||||||
"add_purge_lines": self._add_purge_lines,
|
"add_purge_lines": self._add_purge_lines,
|
||||||
|
@ -195,49 +222,50 @@ class PurgeLinesAndUnload(Script):
|
||||||
data[-1] = self._format_string(data[-1])
|
data[-1] = self._format_string(data[-1])
|
||||||
if self.getSettingValueByKey("add_purge_lines"):
|
if self.getSettingValueByKey("add_purge_lines"):
|
||||||
if self.show_warning:
|
if self.show_warning:
|
||||||
msg_text = "The printer has ( " + str(len(self.disallowed_areas)) + " ) 'disallowed areas'. That can cause the area available for the purge lines to be small.\nOpen the Gcode file for preview in Cura and check the purge line location to insure it is acceptable."
|
msg_text = ("The printer has ( " + str(len(self.disallowed_areas))
|
||||||
|
+ " ) 'disallowed areas'. That can cause the area available for the purge lines to be small.\nOpen the Gcode file for preview in Cura and check the purge line location to insure it is acceptable.")
|
||||||
else:
|
else:
|
||||||
msg_text = "Open the Gcode file for preview in Cura. Make sure the 'Purge Lines' don't run underneath something else and are acceptable."
|
msg_text = "Open the Gcode file for preview in Cura. Make sure the 'Purge Lines' don't run underneath something else and are acceptable."
|
||||||
Message(title="[Purge Lines and Unload]", text=msg_text).show()
|
Message(title="[Purge Lines and Unload]", text=msg_text).show()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _get_real_start_point(self, first_section: str) -> str:
|
def _get_real_start_point(self, first_section: str) -> tuple:
|
||||||
last_x = 0.0
|
last_x, last_y = 0.0, 0.0
|
||||||
last_y = 0.0
|
start_quadrant = Position.LEFT_FRONT
|
||||||
start_quadrant = "LF"
|
|
||||||
startup = first_section.split("\n")
|
for line in first_section.split("\n"):
|
||||||
for line in startup:
|
if line.startswith(";") and not line.startswith(";LAYER_COUNT") or not line:
|
||||||
if (line.startswith(";") and not line.startswith(";LAYER_COUNT")) or line == "":
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if line.startswith("G28"):
|
if line.startswith("G28"):
|
||||||
last_x = 0
|
last_x, last_y = 0.0, 0.0
|
||||||
last_y = 0
|
elif line[:3] in {"G0 ", "G1 "}:
|
||||||
elif line[:3] in ["G0 ", "G1 "]:
|
last_x = self.getValue(line, "X") if " X" in line else last_x
|
||||||
if " X" in line:
|
last_y = self.getValue(line, "Y") if " Y" in line else last_y
|
||||||
last_x = self.getValue(line, "X")
|
|
||||||
if " Y" in line:
|
|
||||||
last_y = self.getValue(line, "Y")
|
|
||||||
# Stop at the Layer Count line to exclude a possible move to the prime tower
|
|
||||||
elif "LAYER_COUNT" in line:
|
elif "LAYER_COUNT" in line:
|
||||||
break
|
break
|
||||||
if self.bed_shape == "rectangular" and not self.origin_at_center:
|
|
||||||
midpoint_x = self.machine_width / 2
|
midpoint_x, midpoint_y = (0.0, 0.0) if self.origin_at_center else (
|
||||||
midpoint_y = self.machine_depth / 2
|
self.machine_width / 2, self.machine_depth / 2)
|
||||||
elif self.origin_at_center:
|
|
||||||
midpoint_x = 0.0
|
|
||||||
midpoint_y = 0.0
|
|
||||||
if last_x <= midpoint_x and last_y <= midpoint_y:
|
if last_x <= midpoint_x and last_y <= midpoint_y:
|
||||||
start_quadrant = "LF"
|
start_quadrant = Position.LEFT_FRONT
|
||||||
elif last_x > midpoint_x and last_y < midpoint_y:
|
elif last_x > midpoint_x and last_y <= midpoint_y:
|
||||||
start_quadrant = "RF"
|
start_quadrant = Position.RIGHT_FRONT
|
||||||
elif last_x > midpoint_x and last_y > midpoint_y:
|
elif last_x > midpoint_x and last_y > midpoint_y:
|
||||||
start_quadrant = "RR"
|
start_quadrant = Position.RIGHT_REAR
|
||||||
elif last_x < midpoint_x and last_y > midpoint_y:
|
elif last_x <= midpoint_x and last_y > midpoint_y:
|
||||||
start_quadrant = "LR"
|
start_quadrant = Position.LEFT_REAR
|
||||||
|
|
||||||
return start_quadrant
|
return start_quadrant
|
||||||
|
|
||||||
# For some multi-extruder printers. Takes into account a 'Move to Prime Tower' if there is one and adds orthogonal travel moves to get there.
|
"""
|
||||||
# 'Move to Prime Tower' does not require that the prime tower is enabled, only that 'machine_extruder_start_position_?' is in the definition file.
|
For some multi-extruder printers.
|
||||||
|
Takes into account a 'Move to Prime Tower' if there is one and adds orthogonal travel moves to get there.
|
||||||
|
'Move to Prime Tower' does not require that the prime tower is enabled,
|
||||||
|
only that 'machine_extruder_start_position_?' is in the definition file.
|
||||||
|
"""
|
||||||
|
|
||||||
def _move_to_prime_tower(self, first_section: str) -> str:
|
def _move_to_prime_tower(self, first_section: str) -> str:
|
||||||
if self.extruder_count == 1:
|
if self.extruder_count == 1:
|
||||||
return first_section
|
return first_section
|
||||||
|
@ -247,77 +275,93 @@ class PurgeLinesAndUnload(Script):
|
||||||
prime_tower_y = self.curaApp.getProperty("prime_tower_position_y", "value")
|
prime_tower_y = self.curaApp.getProperty("prime_tower_position_y", "value")
|
||||||
prime_tower_loc = self._prime_tower_quadrant(prime_tower_x, prime_tower_y)
|
prime_tower_loc = self._prime_tower_quadrant(prime_tower_x, prime_tower_y)
|
||||||
# Shortstop an error if Start Location comes through as None
|
# Shortstop an error if Start Location comes through as None
|
||||||
if self.start_location == None:
|
if self.end_purge_location is None:
|
||||||
self.start_location = "LF"
|
self.end_purge_location = Position.LEFT_FRONT
|
||||||
if prime_tower_loc != self.start_location:
|
if prime_tower_loc != self.end_purge_location:
|
||||||
startup = first_section[1].split("\n")
|
startup = first_section[1].split("\n")
|
||||||
for index, line in enumerate(startup):
|
for index, line in enumerate(startup):
|
||||||
if ";LAYER_COUNT:" in line:
|
if ";LAYER_COUNT:" in line:
|
||||||
try:
|
try:
|
||||||
if startup[index + 1].startswith("G0"):
|
if startup[index + 1].startswith("G0"):
|
||||||
prime_move = startup[index + 1] + " ; Move to Prime Tower"
|
prime_move = startup[index + 1] + " ; Move to Prime Tower"
|
||||||
adjustment_lines = self._get_adjustment_lines(prime_tower_loc)
|
adjustment_lines = self._move_to_location("Prime Tower", prime_tower_loc)
|
||||||
startup[index + 1] = adjustment_lines + prime_move + "\n" + startup[index]
|
startup[index + 1] = adjustment_lines + prime_move + "\n" + startup[index]
|
||||||
startup.pop(index)
|
startup.pop(index)
|
||||||
first_section[1] = "\n".join(startup)
|
first_section[1] = "\n".join(startup)
|
||||||
move_to_prime_present = True
|
move_to_prime_present = True
|
||||||
except:
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
# The start_location changes to the prime tower location in case 'Move to Start' is enabled.
|
# The start_location changes to the prime tower location in case 'Move to Start' is enabled.
|
||||||
if move_to_prime_present:
|
if move_to_prime_present:
|
||||||
self.start_location = prime_tower_loc
|
self.end_purge_location = prime_tower_loc
|
||||||
return first_section
|
return first_section
|
||||||
|
|
||||||
# Determine the quadrant that the prime tower rests in so the orthogonal moves can be calculated
|
# Determine the quadrant that the prime tower rests in so the orthogonal moves can be calculated
|
||||||
def _prime_tower_quadrant(self, prime_tower_x: float, prime_tower_y: float):
|
def _prime_tower_quadrant(self, prime_tower_x: float, prime_tower_y: float) -> tuple:
|
||||||
if not self.origin_at_center:
|
midpoint_x, midpoint_y = (0.0, 0.0) if self.origin_at_center else (
|
||||||
midpoint_x = self.machine_width / 2
|
self.machine_width / 2, self.machine_depth / 2)
|
||||||
midpoint_y = self.machine_depth / 2
|
|
||||||
max_x = self.machine_width - 1
|
|
||||||
min_x = 1
|
|
||||||
max_y = self.machine_depth - 1
|
|
||||||
min_y = 1
|
|
||||||
elif self.origin_at_center:
|
|
||||||
midpoint_x = 0
|
|
||||||
midpoint_y = 0
|
|
||||||
max_x = (self.machine_width / 2) - 1
|
|
||||||
min_x = -abs((self.machine_width / 2) - 1)
|
|
||||||
max_y = (self.machine_depth / 2) - 1
|
|
||||||
min_y = -abs((self.machine_depth / 2) - 1)
|
|
||||||
if prime_tower_x < midpoint_x and prime_tower_y < midpoint_y:
|
if prime_tower_x < midpoint_x and prime_tower_y < midpoint_y:
|
||||||
self.prime_tower_location = "LF"
|
return Position.LEFT_FRONT
|
||||||
elif prime_tower_x > midpoint_x and prime_tower_y < midpoint_y:
|
elif prime_tower_x > midpoint_x and prime_tower_y < midpoint_y:
|
||||||
self.prime_tower_location = "RF"
|
return Position.RIGHT_FRONT
|
||||||
elif prime_tower_x > midpoint_x and prime_tower_y > midpoint_y:
|
elif prime_tower_x > midpoint_x and prime_tower_y > midpoint_y:
|
||||||
self.prime_tower_location = "RR"
|
return Position.RIGHT_REAR
|
||||||
elif prime_tower_x < midpoint_x and prime_tower_y > midpoint_y:
|
elif prime_tower_x < midpoint_x and prime_tower_y > midpoint_y:
|
||||||
self.prime_tower_location = "LR"
|
return Position.LEFT_REAR
|
||||||
return self.prime_tower_location
|
else:
|
||||||
|
return Position.LEFT_FRONT # return Default in case of no match
|
||||||
|
|
||||||
# This puts the 'Move to Prime' tower lines together when they are required
|
def _move_to_location(self, location_name: str, location: tuple) -> str:
|
||||||
def _get_adjustment_lines(self, prime_tower_loc: str):
|
"""
|
||||||
adj_lines = ";MESH:NONMESH---------[Move to Prime Tower]"
|
Compare the input tuple (B) with the end purge location (A) and describe the move from A to B.
|
||||||
if self.start_location == "LF":
|
Parameters:
|
||||||
if prime_tower_loc == "RF":
|
location_name (str): A descriptive name for the target location.
|
||||||
adj_lines += f"\nG0 F{self.speed_travel} X{self.machine_right} ; Start move\nG0 F600 Z0 ; Nail down the string\nG0 F600 Z2 ; Move up\n"
|
location (tuple): The target tuple (e.g., ("right", "front")).
|
||||||
if prime_tower_loc == "RR":
|
Returns:
|
||||||
adj_lines += f"\nG0 F{self.speed_travel} X{self.machine_right} ; Start move\nG0 F600 Z0 ; Nail down the string\nG0 F600 Z2 ; Move up\n"
|
str: G-code for the move from A to B or an empty string if no move is required.
|
||||||
if prime_tower_loc == "LR":
|
"""
|
||||||
adj_lines += f"\nG0 F{self.speed_travel} Y{self.machine_back} ; Start move\nG0 F600 Z0 ; Nail down the string\nG0 F600 Z2 ; Move up\n"
|
# Validate input
|
||||||
elif self.start_location == "RR":
|
if len(self.end_purge_location) != 2 or len(location) != 2:
|
||||||
if prime_tower_loc == "LF":
|
raise ValueError("Both locations must be tuples of length 2.")
|
||||||
adj_lines += f"\nG0 F{self.speed_travel} X{self.machine_left} ; Start move\nG0 F600 Z0 ; Nail down the string\nG0 F600 Z2 ; Move up\n"
|
|
||||||
if prime_tower_loc == "RF":
|
|
||||||
adj_lines += f"\nG0 F{self.speed_travel} Y{self.machine_front} ; Start move\nG0 F600 Z0 ; Nail down the string\nG0 F600 Z2 ; Move up\n"
|
|
||||||
if prime_tower_loc == "LR":
|
|
||||||
adj_lines += f"\nG0 F{self.speed_travel} X{self.machine_left} ; Start move to Prime Tower\nG0 F600 Z0 ; Nail down the string\nG0 F600 Z2 ; Move up\n"
|
|
||||||
return adj_lines
|
|
||||||
|
|
||||||
def _get_build_plate_extents(self) -> float:
|
# Extract components
|
||||||
# Machine disallwed areas can be ordered at the whim of the definition author and cannot be counted on when parsed
|
start_side, start_depth = self.end_purge_location
|
||||||
|
target_side, target_depth = location
|
||||||
|
|
||||||
|
moves = [f";MESH:NONMESH---------[Move to {location_name}]\nG0 F600 Z2 ; Move up\n"]
|
||||||
|
|
||||||
|
# Helper function to add G-code for moves
|
||||||
|
def add_move(axis: str, position: float) -> None:
|
||||||
|
moves.append(
|
||||||
|
f"G0 F{self.speed_travel} {axis}{position} ; Start move\n"
|
||||||
|
f"G0 F600 Z0 ; Nail down the string\n"
|
||||||
|
f"G0 F600 Z2 ; Move up\n"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Compare sides
|
||||||
|
if start_side != target_side:
|
||||||
|
if target_side == Location.RIGHT:
|
||||||
|
add_move("X", self.machine_right)
|
||||||
|
else:
|
||||||
|
add_move("X", self.machine_left)
|
||||||
|
|
||||||
|
# Compare positions
|
||||||
|
if start_depth != target_depth:
|
||||||
|
if target_depth == Location.REAR:
|
||||||
|
add_move("Y", self.machine_back)
|
||||||
|
else:
|
||||||
|
add_move("Y", self.machine_front)
|
||||||
|
if len(moves) <= 1:
|
||||||
|
moves.append(f"G0 F{self.speed_travel} Y{self.start_y} ; Move to start Y\n")
|
||||||
|
# Combine moves into a single G-code string or return a comment if no movement is needed
|
||||||
|
return "".join(moves) if len(moves) > 1 else f";----------[Already at {location_name}, No Moves necessary]\n"
|
||||||
|
|
||||||
|
def _get_build_plate_extents(self):
|
||||||
|
# Machine disallowed areas can be ordered at the whim of the definition author and cannot be counted on when parsed
|
||||||
# This determines a simple rectangle that will be available for the purge lines. For some machines (Ex: UM3) it can be a small rectangle.
|
# This determines a simple rectangle that will be available for the purge lines. For some machines (Ex: UM3) it can be a small rectangle.
|
||||||
if self.bed_shape == "rectangular":
|
if self.bed_shape == "rectangular":
|
||||||
if self.disallowed_areas != []:
|
if self.disallowed_areas:
|
||||||
if len(self.disallowed_areas) > 4:
|
if len(self.disallowed_areas) > 4:
|
||||||
self.show_warning = True
|
self.show_warning = True
|
||||||
mid_x = 0
|
mid_x = 0
|
||||||
|
@ -329,14 +373,14 @@ class PurgeLinesAndUnload(Script):
|
||||||
for rect in self.disallowed_areas:
|
for rect in self.disallowed_areas:
|
||||||
for corner in rect:
|
for corner in rect:
|
||||||
x = corner[0]
|
x = corner[0]
|
||||||
if x < mid_x and x > left_x:
|
if mid_x > x > left_x:
|
||||||
left_x = x
|
left_x = x
|
||||||
if x > mid_x and x < right_x:
|
if mid_x < x < right_x:
|
||||||
right_x = x
|
right_x = x
|
||||||
y = corner[1]
|
y = corner[1]
|
||||||
if y > mid_y and y < front_y:
|
if mid_y < y < front_y:
|
||||||
front_y = y
|
front_y = y
|
||||||
if y < mid_y and y > back_y:
|
if mid_y > y > back_y:
|
||||||
back_y = y
|
back_y = y
|
||||||
if self.origin_at_center:
|
if self.origin_at_center:
|
||||||
self.machine_left = round(left_x + 1, 2)
|
self.machine_left = round(left_x + 1, 2)
|
||||||
|
@ -363,6 +407,9 @@ class PurgeLinesAndUnload(Script):
|
||||||
|
|
||||||
# Add Purge Lines to the user defined position on the build plate
|
# Add Purge Lines to the user defined position on the build plate
|
||||||
def _add_purge_lines(self, data_1: str):
|
def _add_purge_lines(self, data_1: str):
|
||||||
|
def calculate_purge_volume(line_width, purge_length, volume_per_mm):
|
||||||
|
return round((line_width * 0.3 * purge_length) * 1.25 / volume_per_mm, 5)
|
||||||
|
|
||||||
retract_dist = self.extruder[0].getProperty("retraction_amount", "value")
|
retract_dist = self.extruder[0].getProperty("retraction_amount", "value")
|
||||||
retract_enable = self.extruder[0].getProperty("retraction_enable", "value")
|
retract_enable = self.extruder[0].getProperty("retraction_enable", "value")
|
||||||
retract_speed = self.extruder[0].getProperty("retraction_retract_speed", "value") * 60
|
retract_speed = self.extruder[0].getProperty("retraction_retract_speed", "value") * 60
|
||||||
|
@ -376,184 +423,254 @@ class PurgeLinesAndUnload(Script):
|
||||||
|
|
||||||
# Normal cartesian printer with origin at the left front corner
|
# Normal cartesian printer with origin at the left front corner
|
||||||
if self.bed_shape == "rectangular" and not self.origin_at_center:
|
if self.bed_shape == "rectangular" and not self.origin_at_center:
|
||||||
if where_at == "purge_left":
|
if where_at == Location.LEFT:
|
||||||
purge_len = int(self.machine_back - 20) if purge_extrusion_full else int((self.machine_back - self.machine_front) / 2)
|
purge_len = int(self.machine_back - 20) if purge_extrusion_full else int(
|
||||||
|
(self.machine_back - self.machine_front) / 2)
|
||||||
y_stop = int(self.machine_back - 10) if purge_extrusion_full else int(self.machine_depth / 2)
|
y_stop = int(self.machine_back - 10) if purge_extrusion_full else int(self.machine_depth / 2)
|
||||||
purge_volume = round((init_line_width * 0.3 * purge_len) * 1.25 / mm3_per_mm, 5)
|
purge_volume = calculate_purge_volume(init_line_width, purge_len, mm3_per_mm)
|
||||||
|
|
||||||
purge_str = purge_str.replace("Lines", "Lines at MinX")
|
purge_str = purge_str.replace("Lines", "Lines at MinX")
|
||||||
|
# Travel to the purge start
|
||||||
purge_str += f"G0 F{self.speed_travel} X{self.machine_left} Y{self.machine_front + 10} ; Move to start\n"
|
purge_str += f"G0 F{self.speed_travel} X{self.machine_left} Y{self.machine_front + 10} ; Move to start\n"
|
||||||
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
||||||
|
# Purge two lines
|
||||||
purge_str += f"G1 F{print_speed} X{self.machine_left} Y{y_stop} E{purge_volume} ; First line\n"
|
purge_str += f"G1 F{print_speed} X{self.machine_left} Y{y_stop} E{purge_volume} ; First line\n"
|
||||||
purge_str += f"G0 X{self.machine_left + 3} Y{y_stop} ; Move over\n"
|
purge_str += f"G0 X{self.machine_left + 3} Y{y_stop} ; Move over\n"
|
||||||
purge_str += f"G1 F{print_speed} X{self.machine_left + 3} Y{self.machine_front + 10} E{round(purge_volume * 2, 5)} ; Second line\n"
|
purge_str += f"G1 F{print_speed} X{self.machine_left + 3} Y{self.machine_front + 10} E{round(purge_volume * 2, 5)} ; Second line\n"
|
||||||
|
# Retract if enabled
|
||||||
purge_str += f"G1 F{int(retract_speed)} E{round(purge_volume * 2 - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
purge_str += f"G1 F{int(retract_speed)} E{round(purge_volume * 2 - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
||||||
purge_str += "G0 F600 Z8 ; Move Up\nG4 S1 ; Wait for 1 second\n"
|
purge_str += "G0 F600 Z8 ; Move Up\nG4 S1 ; Wait for 1 second\n"
|
||||||
|
# Wipe
|
||||||
purge_str += f"G0 F{print_speed} X{self.machine_left + 3} Y{self.machine_front + 20} Z0.3 ; Slide over and down\n"
|
purge_str += f"G0 F{print_speed} X{self.machine_left + 3} Y{self.machine_front + 20} Z0.3 ; Slide over and down\n"
|
||||||
purge_str += f"G0 X{self.machine_left + 3} Y{self.machine_front + 35} ; Wipe\n"
|
purge_str += f"G0 X{self.machine_left + 3} Y{self.machine_front + 35} ; Wipe\n"
|
||||||
self.start_location = "LF"
|
|
||||||
elif where_at == "purge_right":
|
self.end_purge_location = Position.LEFT_FRONT
|
||||||
purge_len = int(self.machine_depth - 20) if purge_extrusion_full else int((self.machine_back - self.machine_front) / 2)
|
elif where_at == Location.RIGHT:
|
||||||
|
purge_len = int(self.machine_depth - 20) if purge_extrusion_full else int(
|
||||||
|
(self.machine_back - self.machine_front) / 2)
|
||||||
y_stop = int(self.machine_front + 10) if purge_extrusion_full else int(self.machine_depth / 2)
|
y_stop = int(self.machine_front + 10) if purge_extrusion_full else int(self.machine_depth / 2)
|
||||||
purge_volume = round((init_line_width * 0.3 * purge_len) * 1.25 / mm3_per_mm, 5)
|
purge_volume = calculate_purge_volume(init_line_width, purge_len, mm3_per_mm)
|
||||||
|
|
||||||
purge_str = purge_str.replace("Lines", "Lines at MaxX")
|
purge_str = purge_str.replace("Lines", "Lines at MaxX")
|
||||||
|
# Travel to the purge start
|
||||||
purge_str += f"G0 F{self.speed_travel} X{self.machine_right} ; Move\nG0 Y{self.machine_back - 10} ; Move\n"
|
purge_str += f"G0 F{self.speed_travel} X{self.machine_right} ; Move\nG0 Y{self.machine_back - 10} ; Move\n"
|
||||||
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
||||||
|
# Purge two lines
|
||||||
purge_str += f"G1 F{print_speed} X{self.machine_right} Y{y_stop} E{purge_volume} ; First line\n"
|
purge_str += f"G1 F{print_speed} X{self.machine_right} Y{y_stop} E{purge_volume} ; First line\n"
|
||||||
purge_str += f"G0 X{self.machine_right - 3} Y{y_stop} ; Move over\n"
|
purge_str += f"G0 X{self.machine_right - 3} Y{y_stop} ; Move over\n"
|
||||||
purge_str += f"G1 F{print_speed} X{self.machine_right - 3} Y{self.machine_back - 10} E{purge_volume * 2} ; Second line\n"
|
purge_str += f"G1 F{print_speed} X{self.machine_right - 3} Y{self.machine_back - 10} E{purge_volume * 2} ; Second line\n"
|
||||||
|
# Retract if enabled
|
||||||
purge_str += f"G1 F{int(retract_speed)} E{round(purge_volume * 2 - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
purge_str += f"G1 F{int(retract_speed)} E{round(purge_volume * 2 - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
||||||
purge_str += "G0 F600 Z8 ; Move Up\nG4 S1 ; Wait for 1 second\n"
|
purge_str += "G0 F600 Z8 ; Move Up\nG4 S1 ; Wait for 1 second\n"
|
||||||
|
# Wipe
|
||||||
purge_str += f"G0 F{print_speed} X{self.machine_right - 3} Y{self.machine_back - 20} Z0.3 ; Slide over and down\n"
|
purge_str += f"G0 F{print_speed} X{self.machine_right - 3} Y{self.machine_back - 20} Z0.3 ; Slide over and down\n"
|
||||||
purge_str += f"G0 X{self.machine_right - 3} Y{self.machine_back - 35} ; Wipe\n"
|
purge_str += f"G0 X{self.machine_right - 3} Y{self.machine_back - 35} ; Wipe\n"
|
||||||
self.start_location = "RR"
|
|
||||||
elif where_at == "purge_bottom":
|
self.end_purge_location = Position.RIGHT_REAR
|
||||||
purge_len = int(self.machine_width) - 20 if purge_extrusion_full else int((self.machine_right - self.machine_left) / 2)
|
elif where_at == Location.BOTTOM:
|
||||||
|
purge_len = int(self.machine_width) - 20 if purge_extrusion_full else int(
|
||||||
|
(self.machine_right - self.machine_left) / 2)
|
||||||
x_stop = int(self.machine_right - 10) if purge_extrusion_full else int(self.machine_width / 2)
|
x_stop = int(self.machine_right - 10) if purge_extrusion_full else int(self.machine_width / 2)
|
||||||
|
purge_volume = calculate_purge_volume(init_line_width, purge_len, mm3_per_mm)
|
||||||
|
|
||||||
purge_str = purge_str.replace("Lines", "Lines at MinY")
|
purge_str = purge_str.replace("Lines", "Lines at MinY")
|
||||||
purge_volume = round((init_line_width * 0.3 * purge_len) * 1.25 / mm3_per_mm, 5)
|
# Travel to the purge start
|
||||||
purge_str += f"G0 F{self.speed_travel} X{self.machine_left + 10} Y{self.machine_front} ; Move to start\n"
|
purge_str += f"G0 F{self.speed_travel} X{self.machine_left + 10} Y{self.machine_front} ; Move to start\n"
|
||||||
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
||||||
|
# Purge two lines
|
||||||
purge_str += f"G1 F{print_speed} X{x_stop} Y{self.machine_front} E{purge_volume} ; First line\n"
|
purge_str += f"G1 F{print_speed} X{x_stop} Y{self.machine_front} E{purge_volume} ; First line\n"
|
||||||
purge_str += f"G0 X{x_stop} Y{self.machine_front + 3} ; Move over\n"
|
purge_str += f"G0 X{x_stop} Y{self.machine_front + 3} ; Move over\n"
|
||||||
purge_str += f"G1 F{print_speed} X{self.machine_left + 10} Y{self.machine_front + 3} E{purge_volume * 2} ; Second line\n"
|
purge_str += f"G1 F{print_speed} X{self.machine_left + 10} Y{self.machine_front + 3} E{purge_volume * 2} ; Second line\n"
|
||||||
|
# Retract if enabled
|
||||||
purge_str += f"G1 F{int(retract_speed)} E{round(purge_volume * 2 - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
purge_str += f"G1 F{int(retract_speed)} E{round(purge_volume * 2 - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
||||||
purge_str += "G0 F600 Z8 ; Move Up\nG4 S1 ; Wait for 1 second\n"
|
purge_str += "G0 F600 Z8 ; Move Up\nG4 S1 ; Wait for 1 second\n"
|
||||||
|
# Wipe
|
||||||
purge_str += f"G0 F{print_speed} X{self.machine_left + 20} Y{self.machine_front + 3} Z0.3 ; Slide over and down\n"
|
purge_str += f"G0 F{print_speed} X{self.machine_left + 20} Y{self.machine_front + 3} Z0.3 ; Slide over and down\n"
|
||||||
purge_str += f"G0 X{self.machine_left + 35} Y{self.machine_front + 3} ; Wipe\n"
|
purge_str += f"G0 X{self.machine_left + 35} Y{self.machine_front + 3} ; Wipe\n"
|
||||||
self.start_location = "LF"
|
|
||||||
elif where_at == "purge_top":
|
self.end_purge_location = Position.LEFT_FRONT
|
||||||
purge_len = int(self.machine_width - 20) if purge_extrusion_full else int((self.machine_right - self.machine_left)/2)
|
elif where_at == Location.TOP:
|
||||||
|
purge_len = int(self.machine_width - 20) if purge_extrusion_full else int(
|
||||||
|
(self.machine_right - self.machine_left) / 2)
|
||||||
x_stop = int(self.machine_left + 10) if purge_extrusion_full else int(self.machine_width / 2)
|
x_stop = int(self.machine_left + 10) if purge_extrusion_full else int(self.machine_width / 2)
|
||||||
|
purge_volume = calculate_purge_volume(init_line_width, purge_len, mm3_per_mm)
|
||||||
|
|
||||||
purge_str = purge_str.replace("Lines", "Lines at MaxY")
|
purge_str = purge_str.replace("Lines", "Lines at MaxY")
|
||||||
purge_volume = round((init_line_width * 0.3 * purge_len) * 1.25 / mm3_per_mm, 5)
|
# Travel to the purge start
|
||||||
purge_str += f"G0 F{self.speed_travel} Y{self.machine_back} ; Ortho Move to back\n"
|
purge_str += f"G0 F{self.speed_travel} Y{self.machine_back} ; Ortho Move to back\n"
|
||||||
purge_str += f"G0 X{self.machine_right - 10} ; Ortho move to start\n"
|
purge_str += f"G0 X{self.machine_right - 10} ; Ortho move to start\n"
|
||||||
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
||||||
|
# Purge two lines
|
||||||
purge_str += f"G1 F{print_speed} X{x_stop} Y{self.machine_back} E{purge_volume} ; First line\n"
|
purge_str += f"G1 F{print_speed} X{x_stop} Y{self.machine_back} E{purge_volume} ; First line\n"
|
||||||
purge_str += f"G0 X{x_stop} Y{self.machine_back - 3} ; Move over\n"
|
purge_str += f"G0 X{x_stop} Y{self.machine_back - 3} ; Move over\n"
|
||||||
purge_str += f"G1 F{print_speed} X{self.machine_right - 10} Y{self.machine_back - 3} E{purge_volume * 2} ; Second line\n"
|
purge_str += f"G1 F{print_speed} X{self.machine_right - 10} Y{self.machine_back - 3} E{purge_volume * 2} ; Second line\n"
|
||||||
|
# Retract if enabled
|
||||||
purge_str += f"G1 F{int(retract_speed)} E{round(purge_volume * 2 - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
purge_str += f"G1 F{int(retract_speed)} E{round(purge_volume * 2 - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
||||||
purge_str += "G0 F600 Z8 ; Move Up\nG4 S1 ; Wait 1 second\n"
|
purge_str += "G0 F600 Z8 ; Move Up\nG4 S1 ; Wait 1 second\n"
|
||||||
|
# Wipe
|
||||||
purge_str += f"G0 F{print_speed} X{self.machine_right - 20} Y{self.machine_back - 3} Z0.3 ; Slide over and down\n"
|
purge_str += f"G0 F{print_speed} X{self.machine_right - 20} Y{self.machine_back - 3} Z0.3 ; Slide over and down\n"
|
||||||
purge_str += f"G0 X{self.machine_right - 35} Y{self.machine_back - 3} ; Wipe\n"
|
purge_str += f"G0 X{self.machine_right - 35} Y{self.machine_back - 3} ; Wipe\n"
|
||||||
self.start_location = "RR"
|
|
||||||
|
|
||||||
|
self.end_purge_location = Position.RIGHT_REAR
|
||||||
# Some cartesian printers (BIBO, Weedo, MethodX, etc.) are Origin at Center
|
# Some cartesian printers (BIBO, Weedo, MethodX, etc.) are Origin at Center
|
||||||
elif self.bed_shape == "rectangular" and self.origin_at_center:
|
elif self.bed_shape == "rectangular" and self.origin_at_center:
|
||||||
if where_at == "purge_left":
|
if where_at == Location.LEFT:
|
||||||
purge_len = int(self.machine_back - self.machine_front-20) if purge_extrusion_full else abs(int(self.machine_front - 10))
|
purge_len = int(self.machine_back - self.machine_front - 20) if purge_extrusion_full else abs(
|
||||||
|
int(self.machine_front - 10))
|
||||||
y_stop = int(self.machine_back - 10) if purge_extrusion_full else 0
|
y_stop = int(self.machine_back - 10) if purge_extrusion_full else 0
|
||||||
purge_volume = round((init_line_width * 0.3 * purge_len) * 1.25 / mm3_per_mm, 5)
|
purge_volume = calculate_purge_volume(init_line_width, purge_len, mm3_per_mm)
|
||||||
|
# Travel to the purge start
|
||||||
purge_str += f"G0 F{self.speed_travel} X{self.machine_left} Y{self.machine_front + 10} ; Move to start\n"
|
purge_str += f"G0 F{self.speed_travel} X{self.machine_left} Y{self.machine_front + 10} ; Move to start\n"
|
||||||
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
||||||
|
# Purge two lines
|
||||||
purge_str += f"G1 F{print_speed} X{self.machine_left} Y{y_stop} E{purge_volume} ; First line\n"
|
purge_str += f"G1 F{print_speed} X{self.machine_left} Y{y_stop} E{purge_volume} ; First line\n"
|
||||||
purge_str += f"G0 X{self.machine_left + 3} Y{y_stop} ; Move over\n"
|
purge_str += f"G0 X{self.machine_left + 3} Y{y_stop} ; Move over\n"
|
||||||
purge_str += f"G1 F{print_speed} X{self.machine_left + 3} Y{self.machine_front + 10} E{round(purge_volume * 2, 5)} ; Second line\n"
|
purge_str += f"G1 F{print_speed} X{self.machine_left + 3} Y{self.machine_front + 10} E{round(purge_volume * 2, 5)} ; Second line\n"
|
||||||
|
# Retract if enabled
|
||||||
purge_str += f"G1 F{int(retract_speed)} E{round(purge_volume * 2 - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
purge_str += f"G1 F{int(retract_speed)} E{round(purge_volume * 2 - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
||||||
purge_str += "G0 F600 Z8 ; Move Up\nG4 S1 ; Wait for 1 second\n"
|
purge_str += "G0 F600 Z8 ; Move Up\nG4 S1 ; Wait for 1 second\n"
|
||||||
|
# Wipe
|
||||||
purge_str += f"G0 F{print_speed} X{self.machine_left + 3} Y{self.machine_front + 20} Z0.3 ; Slide over and down\n"
|
purge_str += f"G0 F{print_speed} X{self.machine_left + 3} Y{self.machine_front + 20} Z0.3 ; Slide over and down\n"
|
||||||
purge_str += f"G0 X{self.machine_left + 3} Y{self.machine_front + 35} ; Wipe\n"
|
purge_str += f"G0 X{self.machine_left + 3} Y{self.machine_front + 35} ; Wipe\n"
|
||||||
self.start_location = "LF"
|
|
||||||
elif where_at == "purge_right":
|
self.end_purge_location = Position.LEFT_FRONT
|
||||||
purge_len = int(self.machine_back - 20) if purge_extrusion_full else int((self.machine_back - self.machine_front)/2)
|
elif where_at == Location.RIGHT:
|
||||||
|
purge_len = int(self.machine_back - 20) if purge_extrusion_full else int(
|
||||||
|
(self.machine_back - self.machine_front) / 2)
|
||||||
y_stop = int(self.machine_front + 10) if purge_extrusion_full else 0
|
y_stop = int(self.machine_front + 10) if purge_extrusion_full else 0
|
||||||
purge_volume = round((init_line_width * 0.3 * purge_len) * 1.25 / mm3_per_mm, 5)
|
purge_volume = calculate_purge_volume(init_line_width, purge_len, mm3_per_mm)
|
||||||
|
# Travel to the purge start
|
||||||
purge_str += f"G0 F{self.speed_travel} X{self.machine_right} Z2 ; Move\nG0 Y{self.machine_back - 10} Z2 ; Move to start\n"
|
purge_str += f"G0 F{self.speed_travel} X{self.machine_right} Z2 ; Move\nG0 Y{self.machine_back - 10} Z2 ; Move to start\n"
|
||||||
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
||||||
|
# Purge two lines
|
||||||
purge_str += f"G1 F{print_speed} X{self.machine_right} Y{y_stop} E{purge_volume} ; First line\n"
|
purge_str += f"G1 F{print_speed} X{self.machine_right} Y{y_stop} E{purge_volume} ; First line\n"
|
||||||
purge_str += f"G0 X{self.machine_right - 3} Y{y_stop} ; Move over\n"
|
purge_str += f"G0 X{self.machine_right - 3} Y{y_stop} ; Move over\n"
|
||||||
purge_str += f"G1 F{print_speed} X{self.machine_right - 3} Y{self.machine_back - 10} E{purge_volume * 2} ; Second line\n"
|
purge_str += f"G1 F{print_speed} X{self.machine_right - 3} Y{self.machine_back - 10} E{purge_volume * 2} ; Second line\n"
|
||||||
|
# Retract if enabled
|
||||||
purge_str += f"G1 F{int(retract_speed)} E{round(purge_volume * 2 - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
purge_str += f"G1 F{int(retract_speed)} E{round(purge_volume * 2 - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
||||||
purge_str += "G0 F600 Z8 ; Move Up\nG4 S1 ; Wait for 1 second\n"
|
purge_str += "G0 F600 Z8 ; Move Up\nG4 S1 ; Wait for 1 second\n"
|
||||||
|
# Wipe
|
||||||
purge_str += f"G0 F{print_speed} X{self.machine_right - 3} Y{self.machine_back - 20} Z0.3 ; Slide over and down\n"
|
purge_str += f"G0 F{print_speed} X{self.machine_right - 3} Y{self.machine_back - 20} Z0.3 ; Slide over and down\n"
|
||||||
purge_str += f"G0 F{self.speed_travel} X{self.machine_right - 3} Y{self.machine_back - 35} ; Wipe\n"
|
purge_str += f"G0 F{self.speed_travel} X{self.machine_right - 3} Y{self.machine_back - 35} ; Wipe\n"
|
||||||
self.start_location = "RR"
|
|
||||||
elif where_at == "purge_bottom":
|
self.end_purge_location = Position.RIGHT_REAR
|
||||||
purge_len = int(self.machine_right - self.machine_left - 20) if purge_extrusion_full else int((self.machine_right - self.machine_left) / 2)
|
elif where_at == Location.BOTTOM:
|
||||||
|
purge_len = int(self.machine_right - self.machine_left - 20) if purge_extrusion_full else int(
|
||||||
|
(self.machine_right - self.machine_left) / 2)
|
||||||
x_stop = int(self.machine_right - 10) if purge_extrusion_full else 0
|
x_stop = int(self.machine_right - 10) if purge_extrusion_full else 0
|
||||||
purge_volume = round((init_line_width * 0.3 * purge_len) * 1.25 / mm3_per_mm, 5)
|
purge_volume = calculate_purge_volume(init_line_width, purge_len, mm3_per_mm)
|
||||||
|
# Travel to the purge start
|
||||||
purge_str += f"G0 F{self.speed_travel} X{self.machine_left + 10} Z2 ; Move\nG0 Y{self.machine_front} Z2 ; Move to start\n"
|
purge_str += f"G0 F{self.speed_travel} X{self.machine_left + 10} Z2 ; Move\nG0 Y{self.machine_front} Z2 ; Move to start\n"
|
||||||
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
||||||
|
# Purge two lines
|
||||||
purge_str += f"G1 F{print_speed} X{x_stop} Y{self.machine_front} E{purge_volume} ; First line\n"
|
purge_str += f"G1 F{print_speed} X{x_stop} Y{self.machine_front} E{purge_volume} ; First line\n"
|
||||||
purge_str += f"G0 X{x_stop} Y{self.machine_front + 3} ; Move over\n"
|
purge_str += f"G0 X{x_stop} Y{self.machine_front + 3} ; Move over\n"
|
||||||
purge_str += f"G1 F{print_speed} X{self.machine_left + 10} Y{self.machine_front + 3} E{purge_volume * 2} ; Second line\n"
|
purge_str += f"G1 F{print_speed} X{self.machine_left + 10} Y{self.machine_front + 3} E{purge_volume * 2} ; Second line\n"
|
||||||
|
# Retract if enabled
|
||||||
purge_str += f"G1 F{int(retract_speed)} E{round(purge_volume * 2 - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
purge_str += f"G1 F{int(retract_speed)} E{round(purge_volume * 2 - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
||||||
purge_str += "G0 F600 Z8 ; Move Up\nG4 S1 ; Wait for 1 second\n"
|
purge_str += "G0 F600 Z8 ; Move Up\nG4 S1 ; Wait for 1 second\n"
|
||||||
|
# Wipe
|
||||||
purge_str += f"G0 F{print_speed} X{self.machine_left + 20} Y{self.machine_front + 3} Z0.3 ; Slide over and down\n"
|
purge_str += f"G0 F{print_speed} X{self.machine_left + 20} Y{self.machine_front + 3} Z0.3 ; Slide over and down\n"
|
||||||
purge_str += f"G0 F{print_speed} X{self.machine_left + 35} Y{self.machine_front + 3} ; Wipe\n"
|
purge_str += f"G0 F{print_speed} X{self.machine_left + 35} Y{self.machine_front + 3} ; Wipe\n"
|
||||||
self.start_location = "LF"
|
|
||||||
elif where_at == "purge_top":
|
self.end_purge_location = Position.LEFT_FRONT
|
||||||
purge_len = int(self.machine_right - self.machine_left - 20) if purge_extrusion_full else abs(int(self.machine_right - 10))
|
elif where_at == Location.TOP:
|
||||||
|
purge_len = int(self.machine_right - self.machine_left - 20) if purge_extrusion_full else abs(
|
||||||
|
int(self.machine_right - 10))
|
||||||
x_stop = int(self.machine_left + 10) if purge_extrusion_full else 0
|
x_stop = int(self.machine_left + 10) if purge_extrusion_full else 0
|
||||||
purge_volume = round((init_line_width * 0.3 * purge_len) * 1.25 / mm3_per_mm, 5)
|
purge_volume = calculate_purge_volume(init_line_width, purge_len, mm3_per_mm)
|
||||||
|
# Travel to the purge start
|
||||||
purge_str += f"G0 F{self.speed_travel} Y{self.machine_back} Z2; Ortho Move to back\n"
|
purge_str += f"G0 F{self.speed_travel} Y{self.machine_back} Z2; Ortho Move to back\n"
|
||||||
purge_str += f"G0 X{self.machine_right - 10} Z2 ; Ortho Move to start\n"
|
purge_str += f"G0 X{self.machine_right - 10} Z2 ; Ortho Move to start\n"
|
||||||
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
||||||
|
# Purge two lines
|
||||||
purge_str += f"G1 F{print_speed} X{x_stop} Y{self.machine_back} E{purge_volume} ; First line\n"
|
purge_str += f"G1 F{print_speed} X{x_stop} Y{self.machine_back} E{purge_volume} ; First line\n"
|
||||||
purge_str += f"G0 X{x_stop} Y{self.machine_back - 3} ; Move over\n"
|
purge_str += f"G0 X{x_stop} Y{self.machine_back - 3} ; Move over\n"
|
||||||
purge_str += f"G1 F{print_speed} X{self.machine_right - 10} Y{self.machine_back - 3} E{purge_volume * 2} ; Second line\n"
|
purge_str += f"G1 F{print_speed} X{self.machine_right - 10} Y{self.machine_back - 3} E{purge_volume * 2} ; Second line\n"
|
||||||
|
# Retract if enabled
|
||||||
purge_str += f"G1 F{int(retract_speed)} E{round(purge_volume * 2 - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
purge_str += f"G1 F{int(retract_speed)} E{round(purge_volume * 2 - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
||||||
purge_str += "G0 F600 Z8 ; Move Up\nG4 S1 ; Wait for 1 second\n"
|
purge_str += "G0 F600 Z8 ; Move Up\nG4 S1 ; Wait for 1 second\n"
|
||||||
|
# Wipe
|
||||||
purge_str += f"G0 F{print_speed} X{self.machine_right - 20} Y{self.machine_back - 3} Z0.3 ; Slide over and down\n"
|
purge_str += f"G0 F{print_speed} X{self.machine_right - 20} Y{self.machine_back - 3} Z0.3 ; Slide over and down\n"
|
||||||
purge_str += f"G0 F{print_speed} X{self.machine_right - 35} Y{self.machine_back - 3} ; Wipe\n"
|
purge_str += f"G0 F{print_speed} X{self.machine_right - 35} Y{self.machine_back - 3} ; Wipe\n"
|
||||||
self.start_location = "RR"
|
|
||||||
|
|
||||||
|
self.end_purge_location = Position.RIGHT_REAR
|
||||||
# Elliptic printers with Origin at Center
|
# Elliptic printers with Origin at Center
|
||||||
elif self.bed_shape == "elliptic":
|
elif self.bed_shape == "elliptic":
|
||||||
if where_at in ["purge_left","purge_right"]:
|
if where_at in [Location.LEFT, Location.RIGHT]:
|
||||||
radius_1 = round((self.machine_width / 2) - 1, 2)
|
radius_1 = round((self.machine_width / 2) - 1, 2)
|
||||||
elif where_at in ["purge_bottom", "purge_top"]:
|
else: # For where_at in [Location.BOTTOM, Location.TOP]
|
||||||
radius_1 = round((self.machine_depth / 2) - 1, 2)
|
radius_1 = round((self.machine_depth / 2) - 1, 2)
|
||||||
purge_len = int(radius_1) * 3.14159 / 4
|
|
||||||
purge_volume = round((init_line_width * 0.3 * purge_len) * 1.25 / mm3_per_mm, 5)
|
purge_len = int(radius_1) * math.pi / 4
|
||||||
if where_at == "purge_left":
|
purge_volume = calculate_purge_volume(init_line_width, purge_len, mm3_per_mm)
|
||||||
|
|
||||||
|
if where_at == Location.LEFT:
|
||||||
|
# Travel to the purge start
|
||||||
purge_str += f"G0 F{self.speed_travel} X-{round(radius_1 * .707, 2)} Y-{round(radius_1 * .707, 2)} ; Travel\n"
|
purge_str += f"G0 F{self.speed_travel} X-{round(radius_1 * .707, 2)} Y-{round(radius_1 * .707, 2)} ; Travel\n"
|
||||||
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
||||||
|
# Purge two arcs
|
||||||
purge_str += f"G2 F{print_speed} X-{round(radius_1 * .707, 2)} Y{round(radius_1 * .707, 2)} I{round(radius_1 * .707, 2)} J{round(radius_1 * .707, 2)} E{purge_volume} ; First Arc\n"
|
purge_str += f"G2 F{print_speed} X-{round(radius_1 * .707, 2)} Y{round(radius_1 * .707, 2)} I{round(radius_1 * .707, 2)} J{round(radius_1 * .707, 2)} E{purge_volume} ; First Arc\n"
|
||||||
purge_str += f"G0 X-{round((radius_1 - 3) * .707, 2)} Y{round((radius_1 - 3) * .707, 2)} ; Move Over\n"
|
purge_str += f"G0 X-{round((radius_1 - 3) * .707, 2)} Y{round((radius_1 - 3) * .707, 2)} ; Move Over\n"
|
||||||
purge_str += f"G3 F{print_speed} X-{round((radius_1 - 3) * .707, 2)} Y-{round((radius_1 - 3) * .707, 2)} I{round((radius_1 - 3) * .707, 2)} J-{round((radius_1 - 3) * .707, 2)} E{purge_volume * 2} ; Second Arc\n"
|
purge_str += f"G3 F{print_speed} X-{round((radius_1 - 3) * .707, 2)} Y-{round((radius_1 - 3) * .707, 2)} I{round((radius_1 - 3) * .707, 2)} J-{round((radius_1 - 3) * .707, 2)} E{purge_volume * 2} ; Second Arc\n"
|
||||||
purge_str += f"G1 X-{round((radius_1 - 3) * .707 - 25, 2)} E{round(purge_volume * 2 + 1, 5)} ; Move Over\n"
|
purge_str += f"G1 X-{round((radius_1 - 3) * .707 - 25, 2)} E{round(purge_volume * 2 + 1, 5)} ; Move Over\n"
|
||||||
|
# Retract if enabled
|
||||||
purge_str += f"G1 F{int(retract_speed)} E{round((purge_volume * 2 + 1) - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
purge_str += f"G1 F{int(retract_speed)} E{round((purge_volume * 2 + 1) - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
||||||
purge_str += "G0 F600 Z5 ; Move Up\nG4 S1 ; Wait 1 Second\n"
|
purge_str += "G0 F600 Z5 ; Move Up\nG4 S1 ; Wait 1 Second\n"
|
||||||
|
# Wipe
|
||||||
purge_str += f"G0 F{print_speed} X-{round((radius_1 - 3) * .707 - 15, 2)} Z0.3 ; Slide Over\n"
|
purge_str += f"G0 F{print_speed} X-{round((radius_1 - 3) * .707 - 15, 2)} Z0.3 ; Slide Over\n"
|
||||||
purge_str += f"G0 F{print_speed} X-{round((radius_1 - 3) * .707, 2)} ; Wipe\n"
|
purge_str += f"G0 F{print_speed} X-{round((radius_1 - 3) * .707, 2)} ; Wipe\n"
|
||||||
self.start_location = "LF"
|
|
||||||
elif where_at == "purge_right":
|
self.end_purge_location = Position.LEFT_FRONT
|
||||||
|
elif where_at == Location.RIGHT:
|
||||||
|
# Travel to the purge start
|
||||||
purge_str += f"G0 F{self.speed_travel} X{round(radius_1 * .707, 2)} Y-{round(radius_1 * .707, 2)} ; Travel\n"
|
purge_str += f"G0 F{self.speed_travel} X{round(radius_1 * .707, 2)} Y-{round(radius_1 * .707, 2)} ; Travel\n"
|
||||||
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
||||||
|
# Purge two arcs
|
||||||
purge_str += f"G3 F{print_speed} X{round(radius_1 * .707, 2)} Y{round(radius_1 * .707, 2)} I-{round(radius_1 * .707, 2)} J{round(radius_1 * .707, 2)} E{purge_volume} ; First Arc\n"
|
purge_str += f"G3 F{print_speed} X{round(radius_1 * .707, 2)} Y{round(radius_1 * .707, 2)} I-{round(radius_1 * .707, 2)} J{round(radius_1 * .707, 2)} E{purge_volume} ; First Arc\n"
|
||||||
purge_str += f"G0 X{round((radius_1 - 3) * .707, 2)} Y{round((radius_1 - 3) * .707, 2)} ; Move Over\n"
|
purge_str += f"G0 X{round((radius_1 - 3) * .707, 2)} Y{round((radius_1 - 3) * .707, 2)} ; Move Over\n"
|
||||||
purge_str += f"G2 F{print_speed} X{round((radius_1 - 3) * .707, 2)} Y-{round((radius_1 - 3) * .707, 2)} I-{round((radius_1 - 3) * .707, 2)} J-{round((radius_1 - 3) * .707, 2)} E{purge_volume * 2} ; Second Arc\n"
|
purge_str += f"G2 F{print_speed} X{round((radius_1 - 3) * .707, 2)} Y-{round((radius_1 - 3) * .707, 2)} I-{round((radius_1 - 3) * .707, 2)} J-{round((radius_1 - 3) * .707, 2)} E{purge_volume * 2} ; Second Arc\n"
|
||||||
purge_str += f"G1 X{round((radius_1 - 3) * .707 - 25, 2)} E{round(purge_volume * 2 + 1, 5)} ; Move Over\n"
|
purge_str += f"G1 X{round((radius_1 - 3) * .707 - 25, 2)} E{round(purge_volume * 2 + 1, 5)} ; Move Over\n"
|
||||||
|
# Retract if enabled
|
||||||
purge_str += f"G1 F{int(retract_speed)} E{round((purge_volume * 2 + 1) - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
purge_str += f"G1 F{int(retract_speed)} E{round((purge_volume * 2 + 1) - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
||||||
purge_str += "G0 F600 Z5 ; Move Up\nG4 S1 ; Wait 1 Second\n"
|
purge_str += "G0 F600 Z5 ; Move Up\nG4 S1 ; Wait 1 Second\n"
|
||||||
|
# Wipe
|
||||||
purge_str += f"G0 F{print_speed} X{round((radius_1 - 3) * .707 - 15, 2)} Z0.3 ; Slide Over\n"
|
purge_str += f"G0 F{print_speed} X{round((radius_1 - 3) * .707 - 15, 2)} Z0.3 ; Slide Over\n"
|
||||||
purge_str += f"G0 F{print_speed} X{round((radius_1 - 3) * .707,2)}\n"
|
purge_str += f"G0 F{print_speed} X{round((radius_1 - 3) * .707, 2)} ; Wipe\n"
|
||||||
self.start_location = "RR"
|
|
||||||
elif where_at == "purge_bottom":
|
self.end_purge_location = Position.RIGHT_REAR
|
||||||
|
elif where_at == Location.BOTTOM:
|
||||||
|
# Travel to the purge start
|
||||||
purge_str += f"G0 F{self.speed_travel} X-{round(radius_1 * .707, 2)} Y-{round(radius_1 * .707, 2)} ; Travel\n"
|
purge_str += f"G0 F{self.speed_travel} X-{round(radius_1 * .707, 2)} Y-{round(radius_1 * .707, 2)} ; Travel\n"
|
||||||
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
||||||
|
# Purge two arcs
|
||||||
purge_str += f"G3 F{print_speed} X{round(radius_1 * .707, 2)} Y-{round(radius_1 * .707, 2)} I{round(radius_1 * .707, 2)} J{round(radius_1 * .707, 2)} E{purge_volume} ; First Arc\n"
|
purge_str += f"G3 F{print_speed} X{round(radius_1 * .707, 2)} Y-{round(radius_1 * .707, 2)} I{round(radius_1 * .707, 2)} J{round(radius_1 * .707, 2)} E{purge_volume} ; First Arc\n"
|
||||||
purge_str += f"G0 X{round((radius_1 - 3) * .707, 2)} Y-{round((radius_1 - 3) * .707, 2)} ; Move Over\n"
|
purge_str += f"G0 X{round((radius_1 - 3) * .707, 2)} Y-{round((radius_1 - 3) * .707, 2)} ; Move Over\n"
|
||||||
purge_str += f"G2 F{print_speed} X-{round((radius_1 - 3) * .707, 2)} Y-{round((radius_1 - 3) * .707, 2)} I-{round((radius_1 - 3) * .707, 2)} J{round((radius_1 - 3) * .707, 2)} E{purge_volume * 2} ; Second Arc\n"
|
purge_str += f"G2 F{print_speed} X-{round((radius_1 - 3) * .707, 2)} Y-{round((radius_1 - 3) * .707, 2)} I-{round((radius_1 - 3) * .707, 2)} J{round((radius_1 - 3) * .707, 2)} E{purge_volume * 2} ; Second Arc\n"
|
||||||
purge_str += f"G1 Y-{round((radius_1 - 3) * .707 - 25, 2)} E{round(purge_volume * 2 + 1, 5)} ; Move Over\n"
|
purge_str += f"G1 Y-{round((radius_1 - 3) * .707 - 25, 2)} E{round(purge_volume * 2 + 1, 5)} ; Move Over\n"
|
||||||
|
# Retract if enabled
|
||||||
purge_str += f"G1 F{int(retract_speed)} E{round((purge_volume * 2 + 1) - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
purge_str += f"G1 F{int(retract_speed)} E{round((purge_volume * 2 + 1) - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
||||||
purge_str += "G0 F600 Z5 ; Move Up\nG4 S1 ; Wait 1 Second\n"
|
purge_str += "G0 F600 Z5 ; Move Up\nG4 S1 ; Wait 1 Second\n"
|
||||||
|
# Wipe
|
||||||
purge_str += f"G0 F{print_speed} Y-{round((radius_1 - 3) * .707 - 15, 2)} Z0.3 ; Slide Over\n"
|
purge_str += f"G0 F{print_speed} Y-{round((radius_1 - 3) * .707 - 15, 2)} Z0.3 ; Slide Over\n"
|
||||||
purge_str += f"G0 F{print_speed} Y-{round((radius_1 - 3) * .707,2)}\n"
|
purge_str += f"G0 F{print_speed} Y-{round((radius_1 - 3) * .707, 2)} ; Wipe\n"
|
||||||
self.start_location = "LF"
|
self.end_purge_location = Position.LEFT_FRONT
|
||||||
elif where_at == "purge_top":
|
elif where_at == Location.TOP:
|
||||||
|
# Travel to the purge start
|
||||||
purge_str += f"G0 F{self.speed_travel} X{round(radius_1 * .707, 2)} Y{round(radius_1 * .707, 2)} ; Travel\n"
|
purge_str += f"G0 F{self.speed_travel} X{round(radius_1 * .707, 2)} Y{round(radius_1 * .707, 2)} ; Travel\n"
|
||||||
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
purge_str += f"G0 F600 Z0.3 ; Move down\n"
|
||||||
|
# Purge two arcs
|
||||||
purge_str += f"G3 F{print_speed} X-{round(radius_1 * .707, 2)} Y{round(radius_1 * .707, 2)} I-{round(radius_1 * .707, 2)} J-{round(radius_1 * .707, 2)} E{purge_volume} ; First Arc\n"
|
purge_str += f"G3 F{print_speed} X-{round(radius_1 * .707, 2)} Y{round(radius_1 * .707, 2)} I-{round(radius_1 * .707, 2)} J-{round(radius_1 * .707, 2)} E{purge_volume} ; First Arc\n"
|
||||||
purge_str += f"G0 X-{round((radius_1 - 3) * .707, 2)} Y{round((radius_1 - 3) * .707, 2)} ; Move Over\n"
|
purge_str += f"G0 X-{round((radius_1 - 3) * .707, 2)} Y{round((radius_1 - 3) * .707, 2)} ; Move Over\n"
|
||||||
purge_str += f"G2 F{print_speed} X{round((radius_1 - 3) * .707, 2)} Y{round((radius_1 - 3) * .707, 2)} I{round((radius_1 - 3) * .707, 2)} J-{round((radius_1 - 3) * .707, 2)} E{purge_volume * 2} ; Second Arc\n"
|
purge_str += f"G2 F{print_speed} X{round((radius_1 - 3) * .707, 2)} Y{round((radius_1 - 3) * .707, 2)} I{round((radius_1 - 3) * .707, 2)} J-{round((radius_1 - 3) * .707, 2)} E{purge_volume * 2} ; Second Arc\n"
|
||||||
purge_str += f"G1 Y{round((radius_1 - 3) * .707 - 25, 2)} E{round(purge_volume * 2 + 1, 5)} ; Move Over\n"
|
purge_str += f"G1 Y{round((radius_1 - 3) * .707 - 25, 2)} E{round(purge_volume * 2 + 1, 5)} ; Move Over\n"
|
||||||
|
# Retract if enabled
|
||||||
purge_str += f"G1 F{int(retract_speed)} E{round((purge_volume * 2 + 1) - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
purge_str += f"G1 F{int(retract_speed)} E{round((purge_volume * 2 + 1) - retract_dist, 5)} ; Retract\n" if retract_enable else ""
|
||||||
purge_str += "G0 F600 Z5\nG4 S1\n"
|
purge_str += "G0 F600 Z5\nG4 S1 ; Wait 1 Second\n"
|
||||||
|
# Wipe
|
||||||
purge_str += f"G0 F{print_speed} Y{round((radius_1 - 3) * .707 - 15, 2)} Z0.3 ; Slide Over\n"
|
purge_str += f"G0 F{print_speed} Y{round((radius_1 - 3) * .707 - 15, 2)} Z0.3 ; Slide Over\n"
|
||||||
purge_str += f"G0 F{print_speed} Y{round((radius_1 - 3) * .707,2)}\n"
|
purge_str += f"G0 F{print_speed} Y{round((radius_1 - 3) * .707, 2)} ; Wipe\n"
|
||||||
self.start_location = "RR"
|
self.end_purge_location = Position.RIGHT_REAR
|
||||||
|
|
||||||
# Common ending for purge_str
|
# Common ending for purge_str
|
||||||
purge_str += "G0 F600 Z2 ; Move Z\n;---------------------[End of Purge]"
|
purge_str += "G0 F600 Z2 ; Move Z\n;---------------------[End of Purge]"
|
||||||
|
@ -567,7 +684,7 @@ class PurgeLinesAndUnload(Script):
|
||||||
while not startup[next_line].startswith("G92 E0"):
|
while not startup[next_line].startswith("G92 E0"):
|
||||||
startup[next_line] = ";" + startup[next_line]
|
startup[next_line] = ";" + startup[next_line]
|
||||||
next_line += 1
|
next_line += 1
|
||||||
except:
|
except IndexError:
|
||||||
break
|
break
|
||||||
data_1[1] = "\n".join(startup)
|
data_1[1] = "\n".join(startup)
|
||||||
|
|
||||||
|
@ -590,218 +707,121 @@ class PurgeLinesAndUnload(Script):
|
||||||
|
|
||||||
# Travel moves around the bed periphery to keep strings from crossing the footprint of the model.
|
# Travel moves around the bed periphery to keep strings from crossing the footprint of the model.
|
||||||
def _move_to_start(self, data: str) -> str:
|
def _move_to_start(self, data: str) -> str:
|
||||||
start_x = None
|
self.start_x = None
|
||||||
start_y = None
|
self.start_y = None
|
||||||
|
move_str = None
|
||||||
layer = data[2].split("\n")
|
layer = data[2].split("\n")
|
||||||
for line in layer:
|
for line in layer:
|
||||||
if line.startswith("G0") and " X" in line and " Y" in line:
|
if line.startswith("G0") and " X" in line and " Y" in line:
|
||||||
start_x = self.getValue(line, "X")
|
self.start_x = self.getValue(line, "X")
|
||||||
start_y = self.getValue(line, "Y")
|
self.start_y = self.getValue(line, "Y")
|
||||||
break
|
break
|
||||||
if start_x == None: start_x = 0
|
self.start_x = self.start_x or 0
|
||||||
if start_y == None: start_y = 0
|
self.start_y = self.start_y or 0
|
||||||
if self.start_location == None:
|
if self.end_purge_location is None:
|
||||||
self.start_location = "LF"
|
self.end_purge_location = Position.LEFT_FRONT
|
||||||
move_str = f";MESH:NONMESH---------[Travel to Layer Start]\nG0 F600 Z2 ; Move up\n"
|
|
||||||
midpoint_x = self.machine_width / 2
|
midpoint_x = self.machine_width / 2
|
||||||
midpoint_y = self.machine_depth / 2
|
midpoint_y = self.machine_depth / 2
|
||||||
if not self.origin_at_center:
|
if not self.origin_at_center:
|
||||||
if float(start_x) <= float(midpoint_x):
|
if float(self.start_x) <= float(midpoint_x):
|
||||||
goto_str = "Lt"
|
x_target = Location.LEFT
|
||||||
else:
|
else:
|
||||||
goto_str = "Rt"
|
x_target = Location.RIGHT
|
||||||
if float(start_y) <= float(midpoint_y):
|
if float(self.start_y) <= float(midpoint_y):
|
||||||
goto_str += "Frt"
|
y_target = Location.FRONT
|
||||||
else:
|
else:
|
||||||
goto_str += "Bk"
|
y_target = Location.REAR
|
||||||
else:
|
else:
|
||||||
if float(start_x) <= 0:
|
if float(self.start_x) <= 0:
|
||||||
goto_str = "Lt"
|
x_target = Location.LEFT
|
||||||
else:
|
else:
|
||||||
goto_str = "Rt"
|
x_target = Location.RIGHT
|
||||||
if float(start_y) <= 0:
|
if float(self.start_y) <= 0:
|
||||||
goto_str += "Frt"
|
y_target = Location.FRONT
|
||||||
else:
|
else:
|
||||||
goto_str += "Bk"
|
y_target = Location.REAR
|
||||||
|
target_location = (x_target, y_target)
|
||||||
# Depending on which quadrant the XY layer start is, move around the periphery before coming in to the start position
|
if self.bed_shape == "rectangular":
|
||||||
if self.bed_shape == "rectangular" and not self.origin_at_center:
|
move_str = self._move_to_location("Layer Start", target_location)
|
||||||
if self.start_location == "LF":
|
|
||||||
if goto_str == "LtFrt":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X{self.machine_right - 5} ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
move_str += f"G0 F{self.speed_travel} Y{self.machine_front + 5} ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
elif goto_str == "RtFrt":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X{self.machine_left + 5} Z2; Ortho Move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
move_str += f"G0 F{self.speed_travel} Y{self.machine_front + 5} Z2 ; Ortho Move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
move_str += f"G0 F{self.speed_travel} X{start_x} ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
elif goto_str == "LtBk":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X{self.machine_left + 5} ; Ortho Move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
move_str += f"G0 F{self.speed_travel} Y{self.machine_front + 5} Z2 ; Move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
move_str += f"G0 F{self.speed_travel} Y{start_y} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
elif goto_str == "RtBk":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X{self.machine_left + 5} ; Move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
move_str += f"G0 F{self.speed_travel} Y{self.machine_front + 5} Z2 ; Move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
move_str += f"G0 F{self.speed_travel} X{self.machine_right - 5} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
move_str += f"G0 F{self.speed_travel} Y{start_y} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
elif self.start_location == "RR":
|
|
||||||
if goto_str == "LtFrt":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X{self.machine_left + 5} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
move_str += f"G0 F{self.speed_travel} Y{self.machine_front + 5} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
elif goto_str == "RtFrt":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X{start_x} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
move_str += f"G0 F{self.speed_travel} Y{self.machine_front + 5} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
elif goto_str == "LtBk":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X{self.machine_left + 5} Z2 ; Move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
elif goto_str == "RtBk":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X{self.machine_right - 5} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
move_str += f"G0 F{self.speed_travel} Y{start_y} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
|
|
||||||
elif self.bed_shape == "rectangular" and self.origin_at_center:
|
|
||||||
if self.start_location == "LF":
|
|
||||||
if goto_str == "LtFrt":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X{self.machine_left + 5} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
move_str += f"G0 F{self.speed_travel} Y{self.machine_back - 5} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
elif goto_str == "RtFrt":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X{self.machine_right - 5} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
move_str += f"G0 F{self.speed_travel} Y{self.machine_back - 5} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
elif goto_str == "LtBk":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X{self.machine_right - 5} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
move_str += f"G0 F{self.speed_travel} Y{self.machine_back - 5} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
elif goto_str == "RtBk":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X{self.machine_right - 5} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
move_str += f"G0 F{self.speed_travel} Y{self.machine_back - 5} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
elif self.start_location == "RR":
|
|
||||||
if goto_str == "LtFrt":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X{self.machine_right - 5} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
move_str += f"G0 F{self.speed_travel} Y{self.machine_back - 5} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
elif goto_str == "RtFrt":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X{self.machine_right - 5} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
move_str += f"G0 F{self.speed_travel} Y{self.machine_back - 5} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
elif goto_str == "LtBk":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X{self.machine_right - 5} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
move_str += f"G0 F{self.speed_travel} Y{self.machine_back - 5} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
elif goto_str == "RtBk":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X{self.machine_right - 5} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
move_str += f"G0 F{self.speed_travel} Y{self.machine_back - 5} Z2 ; Ortho move\n"
|
|
||||||
move_str += f"G0 F600 Z0 ; Nail down the string\nG0 Z2 ; Move up\n"
|
|
||||||
|
|
||||||
elif self.bed_shape == "elliptic" and self.origin_at_center:
|
elif self.bed_shape == "elliptic" and self.origin_at_center:
|
||||||
|
move_str = f";MESH:NONMESH---------[Travel to Layer Start]\nG0 F600 Z2 ; Move up\n"
|
||||||
|
|
||||||
radius = self.machine_width / 2
|
radius = self.machine_width / 2
|
||||||
offset_sin = round(2 ** .5 / 2 * radius, 2)
|
offset_sin = round(2 ** .5 / 2 * radius, 2)
|
||||||
if self.start_location == "LR":
|
if target_location == Position.LEFT_FRONT:
|
||||||
if goto_str == "LtFrt":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X-{offset_sin} Z2 ; Move\nG0 Y-{offset_sin} Z2 ; Move to start\n"
|
move_str += f"G0 F{self.speed_travel} X-{offset_sin} Z2 ; Move\nG0 Y-{offset_sin} Z2 ; Move to start\n"
|
||||||
elif goto_str == "LtBk":
|
elif target_location == Position.LEFT_REAR:
|
||||||
|
if self.end_purge_location == Position.LEFT_REAR:
|
||||||
move_str += f"G2 X0 Y{offset_sin} I{offset_sin} J{offset_sin} ; Move around to start\n"
|
move_str += f"G2 X0 Y{offset_sin} I{offset_sin} J{offset_sin} ; Move around to start\n"
|
||||||
elif goto_str == "RtFrt":
|
else:
|
||||||
move_str += f"G0 F{self.speed_travel} X{offset_sin} Z2 ; Ortho move\nG0 Y-{offset_sin} Z2 ; Ortho move\n"
|
|
||||||
elif goto_str == "RtBk":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X{offset_sin} Z2 ; Ortho move\nG0 Y{offset_sin} Z2 ; Ortho move\n"
|
|
||||||
elif self.start_location == "RR":
|
|
||||||
if goto_str == "LtFrt":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X-{offset_sin} Z2 ; Move\nG0 Y-{offset_sin} Z2 ; Move to start\n"
|
|
||||||
elif goto_str == "LtBk":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X-{offset_sin} Z2 ; Ortho move\nG0 Y{offset_sin} Z2 ; Ortho move\n"
|
move_str += f"G0 F{self.speed_travel} X-{offset_sin} Z2 ; Ortho move\nG0 Y{offset_sin} Z2 ; Ortho move\n"
|
||||||
elif goto_str == "RtFrt":
|
elif target_location == Position.RIGHT_FRONT:
|
||||||
move_str += f"G0 F{self.speed_travel} X{offset_sin} Z2 ; Ortho move\nG0 Y-{offset_sin} Z2 ; Ortho move\n"
|
move_str += f"G0 F{self.speed_travel} X{offset_sin} Z2 ; Ortho move\nG0 Y-{offset_sin} Z2 ; Ortho move\n"
|
||||||
elif goto_str == "RtBk":
|
elif target_location == Position.RIGHT_REAR:
|
||||||
move_str += f"G0 F{self.speed_travel} X{offset_sin} Z2 ; Ortho move\nG0 Y{offset_sin} Z2 ; Ortho move\n"
|
|
||||||
elif self.start_location == "LF":
|
|
||||||
if goto_str == "LtFrt":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X-{offset_sin} Z2 ; Move\nG0 Y-{offset_sin} Z2 ; Move to start\n"
|
|
||||||
elif goto_str == "LtBk":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X-{offset_sin} Z2 ; Ortho move\nG0 Y{offset_sin} Z2 ; Ortho move\n"
|
|
||||||
elif goto_str == "RtFrt":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X{offset_sin} Z2 ; Ortho move\nG0 Y-{offset_sin} Z2 ; Ortho move\n"
|
|
||||||
elif goto_str == "RtBk":
|
|
||||||
move_str += f"G0 F{self.speed_travel} X{offset_sin} Z2 ; Ortho move\nG0 Y{offset_sin} Z2 ; Ortho move\n"
|
move_str += f"G0 F{self.speed_travel} X{offset_sin} Z2 ; Ortho move\nG0 Y{offset_sin} Z2 ; Ortho move\n"
|
||||||
move_str += ";---------------------[End of layer start travels]"
|
move_str += ";---------------------[End of layer start travels]"
|
||||||
# Add the move_str to the end of the StartUp section and move 'LAYER_COUNT' to the end.
|
# Add the move_str to the end of the StartUp section and move 'LAYER_COUNT' to the end.
|
||||||
startup = data[1].split("\n")
|
startup = data[1].split("\n")
|
||||||
for index, line in enumerate(startup):
|
|
||||||
if "LAYER_COUNT" in line:
|
|
||||||
lay_count = startup.pop(index) + "\n"
|
|
||||||
break
|
|
||||||
move_str = self._format_string(move_str)
|
move_str = self._format_string(move_str)
|
||||||
if move_str.startswith("\n"):
|
if move_str.startswith("\n"):
|
||||||
move_str = move_str[1:]
|
move_str = move_str[1:]
|
||||||
startup.append(move_str)
|
startup.append(move_str)
|
||||||
|
|
||||||
|
for index, line in enumerate(startup):
|
||||||
|
if "LAYER_COUNT" in line:
|
||||||
|
lay_count = startup.pop(index) + "\n"
|
||||||
startup.append(lay_count)
|
startup.append(lay_count)
|
||||||
|
break
|
||||||
|
|
||||||
data[1] = "\n".join(startup)
|
data[1] = "\n".join(startup)
|
||||||
# Remove any double spaced lines
|
# Remove any double-spaced lines
|
||||||
data[1] = data[1].replace("\n\n", "\n")
|
data[1] = data[1].replace("\n\n", "\n")
|
||||||
return
|
return data
|
||||||
|
|
||||||
# Unloading a large amount of filament in a single command can trip the 'Overlong Extrusion' warning in some firmware. Unloads longer than 150mm are split into individual 150mm segments.
|
# Unloading a large amount of filament in a single command can trip the 'Overlong Extrusion' warning in some firmware. Unloads longer than 150mm are split into individual 150mm segments.
|
||||||
def _unload_filament(self, data: str) -> str:
|
def _unload_filament(self, data: str) -> str:
|
||||||
extrude_speed = 3000
|
extrude_speed = 3000
|
||||||
quick_purge_speed = 240
|
quick_purge_speed = 240
|
||||||
retract_amount = self.extruder[0].getProperty("retraction_amount", "value")
|
retract_amount = self.extruder[0].getProperty("retraction_amount", "value")
|
||||||
if retract_amount < 2.0:
|
quick_purge_amount = retract_amount + 5 if retract_amount < 2.0 else retract_amount * 2
|
||||||
quick_purge_amount = retract_amount + 5
|
|
||||||
else:
|
|
||||||
quick_purge_amount = retract_amount * 2
|
|
||||||
unload_distance = self.getSettingValueByKey("unload_distance")
|
unload_distance = self.getSettingValueByKey("unload_distance")
|
||||||
quick_purge = self.getSettingValueByKey("unload_quick_purge")
|
quick_purge = self.getSettingValueByKey("unload_quick_purge")
|
||||||
lines = data[len(data) - 1].split("\n")
|
|
||||||
|
lines = data[-1].split("\n")
|
||||||
for index, line in enumerate(lines):
|
for index, line in enumerate(lines):
|
||||||
# Unload the filament just before the hot end turns off.
|
# Unload the filament just before the hot end turns off.
|
||||||
if line.startswith("M104") and "S0" in line:
|
if line.startswith("M104") and "S0" in line:
|
||||||
filament_str = "M83 ; [Unload] Relative extrusion\nM400 ; Complete all moves\n"
|
filament_str = (
|
||||||
|
"M83 ; [Unload] Relative extrusion\n"
|
||||||
|
"M400 ; Complete all moves\n"
|
||||||
|
)
|
||||||
if quick_purge:
|
if quick_purge:
|
||||||
filament_str += f"G1 F{quick_purge_speed} E{quick_purge_amount} ; Quick Purge before unload\n"
|
filament_str += f"G1 F{quick_purge_speed} E{quick_purge_amount} ; Quick Purge before unload\n"
|
||||||
|
|
||||||
if unload_distance > 150:
|
if unload_distance > 150:
|
||||||
temp_unload = unload_distance
|
filament_str += "".join(
|
||||||
while temp_unload > 150:
|
f"G1 F{extrude_speed} E-150 ; Unload some\n"
|
||||||
filament_str += "G1 F" + str(int(extrude_speed)) + " E-150 ; Unload some\n"
|
for _ in range(unload_distance // 150)
|
||||||
temp_unload -= 150
|
)
|
||||||
if 0 < temp_unload <= 150:
|
remaining_unload = unload_distance % 150
|
||||||
filament_str += "G1 F" + str(int(extrude_speed)) + " E-" + str(temp_unload) + " ; Unload the remainder\nM82 ; Absolute Extrusion\nG92 E0 ; Reset Extruder\n"
|
if remaining_unload > 0:
|
||||||
|
filament_str += f"G1 F{extrude_speed} E-{remaining_unload} ; Unload the remainder\n"
|
||||||
else:
|
else:
|
||||||
filament_str += "G1 F" + str(int(extrude_speed)) + " E-" + str(unload_distance) + " ; Unload\nM82 ; Absolute Extrusion\nG92 E0 ; Reset Extruder\n"
|
filament_str += f"G1 F{extrude_speed} E-{unload_distance} ; Unload\n"
|
||||||
|
|
||||||
|
filament_str += (
|
||||||
|
"M82 ; Absolute Extrusion\n"
|
||||||
|
"G92 E0 ; Reset Extruder\n"
|
||||||
|
)
|
||||||
|
lines[index] = filament_str + line
|
||||||
break
|
break
|
||||||
lines[index] = filament_str + lines[index]
|
|
||||||
data[len(data) - 1] = "\n".join(lines)
|
data[-1] = "\n".join(lines)
|
||||||
return
|
return data
|
||||||
|
|
||||||
# Make an adjustment to the starting E location so the skirt/brim/raft starts out when the nozzle starts out.
|
# Make an adjustment to the starting E location so the skirt/brim/raft starts out when the nozzle starts out.
|
||||||
def _adjust_starting_e(self, data: str) -> str:
|
def _adjust_starting_e(self, data: str) -> str:
|
||||||
retract_enabled = self.extruder[0].getProperty("retraction_enable", "value")
|
if not self.extruder[0].getProperty("retraction_enable", "value"):
|
||||||
if not retract_enabled:
|
|
||||||
return
|
return
|
||||||
adjust_amt = self.getSettingValueByKey("adjust_e_loc_to")
|
adjust_amt = self.getSettingValueByKey("adjust_e_loc_to")
|
||||||
lines = data[1].split("\n")
|
lines = data[1].split("\n")
|
||||||
|
@ -816,7 +836,7 @@ class PurgeLinesAndUnload(Script):
|
||||||
lines.reverse()
|
lines.reverse()
|
||||||
data[1] = "\n".join(lines)
|
data[1] = "\n".join(lines)
|
||||||
break
|
break
|
||||||
return
|
return data
|
||||||
|
|
||||||
# Format the purge or travel-to-start strings. No reason they shouldn't look nice.
|
# Format the purge or travel-to-start strings. No reason they shouldn't look nice.
|
||||||
def _format_string(self, any_gcode_str: str):
|
def _format_string(self, any_gcode_str: str):
|
||||||
|
@ -829,9 +849,13 @@ class PurgeLinesAndUnload(Script):
|
||||||
if gap_len < 30: gap_len = 30
|
if gap_len < 30: gap_len = 30
|
||||||
for temp_index, temp_line in enumerate(temp_lines):
|
for temp_index, temp_line in enumerate(temp_lines):
|
||||||
if ";" in temp_line and not temp_line.startswith(";"):
|
if ";" in temp_line and not temp_line.startswith(";"):
|
||||||
temp_lines[temp_index] = temp_line.replace(temp_line.split(";")[0], temp_line.split(";")[0] + str(" " * (gap_len - len(temp_line.split(";")[0]))),1)
|
temp_lines[temp_index] = temp_line.replace(temp_line.split(";")[0], temp_line.split(";")[0] + str(
|
||||||
|
" " * (gap_len - len(temp_line.split(";")[0]))), 1)
|
||||||
# This formats lines that are commented out but contain additional comments Ex: ;M420 ; leveling mesh
|
# This formats lines that are commented out but contain additional comments Ex: ;M420 ; leveling mesh
|
||||||
elif temp_line.startswith(";") and ";" in temp_line[1:]:
|
elif temp_line.startswith(";") and ";" in temp_line[1:]:
|
||||||
temp_lines[temp_index] = temp_line[1:].replace(temp_line[1:].split(";")[0], ";" + temp_line[1:].split(";")[0] + str(" " * (gap_len - 1 - len(temp_line[1:].split(";")[0]))),1)
|
temp_lines[temp_index] = temp_line[1:].replace(temp_line[1:].split(";")[0],
|
||||||
|
";" + temp_line[1:].split(";")[0] + str(" " * (
|
||||||
|
gap_len - 1 - len(
|
||||||
|
temp_line[1:].split(";")[0]))), 1)
|
||||||
any_gcode_str = "\n".join(temp_lines)
|
any_gcode_str = "\n".join(temp_lines)
|
||||||
return any_gcode_str
|
return any_gcode_str
|
Loading…
Add table
Add a link
Reference in a new issue