mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Merge pull request #16805 from GregValiant/LimitXYAccelJerk
Update LimitXYAccelJerk
This commit is contained in:
commit
1433c38374
1 changed files with 53 additions and 30 deletions
|
@ -8,6 +8,7 @@
|
|||
# This post is intended for printers with moving beds (bed slingers) so UltiMaker printers are excluded.
|
||||
# When setting an accel limit on multi-extruder printers ALL extruders are effected.
|
||||
# This post does not distinguish between Print Accel and Travel Accel. The limit is the limit for all regardless. Example: Skin Accel = 1000 and Outer Wall accel = 500. If the limit is set to 300 then both Skin and Outer Wall will be Accel = 300.
|
||||
# 9/15/2023 added support for RepRap M566 command for Jerk in mm/min
|
||||
|
||||
from ..Script import Script
|
||||
from cura.CuraApplication import CuraApplication
|
||||
|
@ -31,9 +32,14 @@ class LimitXYAccelJerk(Script):
|
|||
self._instance.setProperty("y_jerk", "value", jerk_print_old)
|
||||
ext_count = int(mycura.getProperty("machine_extruder_count", "value"))
|
||||
machine_name = str(mycura.getProperty("machine_name", "value"))
|
||||
if str(mycura.getProperty("machine_gcode_flavor", "value")) == "RepRap (RepRap)":
|
||||
self._instance.setProperty("jerk_cmd", "value", "reprap_flavor")
|
||||
else:
|
||||
self._instance.setProperty("jerk_cmd", "value", "marlin_flavor")
|
||||
firmware_flavor = str(mycura.getProperty("machine_gcode_flavor", "value"))
|
||||
|
||||
# Warn the user if the printer is an Ultimaker-------------------------
|
||||
if "Ultimaker" in machine_name:
|
||||
if "Ultimaker" in machine_name or "UltiGCode" in firmware_flavor or "Griffin" in firmware_flavor:
|
||||
Message(text = "<NOTICE> [Limit the X-Y Accel/Jerk] DID NOT RUN because Ultimaker printers don't have sliding beds.").show()
|
||||
|
||||
# Warn the user if the printer is multi-extruder------------------
|
||||
|
@ -86,6 +92,17 @@ class LimitXYAccelJerk(Script):
|
|||
"enabled": true,
|
||||
"default_value": false
|
||||
},
|
||||
"jerk_cmd":
|
||||
{
|
||||
"label": "G-Code Jerk Command",
|
||||
"description": "Marlin uses M205. RepRap might use M566.",
|
||||
"type": "enum",
|
||||
"options": {
|
||||
"marlin_flavor": "M205",
|
||||
"reprap_flavor": "M566"},
|
||||
"default_value": "marlin_flavor",
|
||||
"enabled": "jerk_enable"
|
||||
},
|
||||
"x_jerk":
|
||||
{
|
||||
"label": " X jerk",
|
||||
|
@ -174,7 +191,6 @@ class LimitXYAccelJerk(Script):
|
|||
jerk_travel_enabled = str(extruder[0].getProperty("jerk_travel_enabled", "value"))
|
||||
jerk_print_old = extruder[0].getProperty("jerk_print", "value")
|
||||
jerk_travel_old = extruder[0].getProperty("jerk_travel", "value")
|
||||
|
||||
if int(accel_print) >= int(accel_travel):
|
||||
accel_old = accel_print
|
||||
else:
|
||||
|
@ -190,20 +206,27 @@ class LimitXYAccelJerk(Script):
|
|||
y_accel = str(self.getSettingValueByKey("y_accel_limit"))
|
||||
x_jerk = int(self.getSettingValueByKey("x_jerk"))
|
||||
y_jerk = int(self.getSettingValueByKey("y_jerk"))
|
||||
if str(self.getSettingValueByKey("jerk_cmd")) == "reprap_flavor":
|
||||
jerk_cmd = "M566"
|
||||
x_jerk *= 60
|
||||
y_jerk *= 60
|
||||
jerk_old *= 60
|
||||
else:
|
||||
jerk_cmd = "M205"
|
||||
|
||||
# Put the strings together-------------------------------------------
|
||||
m201_limit_new = "M201 X" + x_accel + " Y" + y_accel
|
||||
m201_limit_old = "M201 X" + str(round(accel_old)) + " Y" + str(round(accel_old))
|
||||
m201_limit_new = f"M201 X{x_accel} Y{y_accel}"
|
||||
m201_limit_old = f"M201 X{round(accel_old)} Y{round(accel_old)}"
|
||||
if x_jerk == 0:
|
||||
m205_jerk_pattern = "Y(\d*)"
|
||||
m205_jerk_new = "Y" + str(y_jerk)
|
||||
m205_jerk_new = f"Y{y_jerk}"
|
||||
if y_jerk == 0:
|
||||
m205_jerk_pattern = "X(\d*)"
|
||||
m205_jerk_new = "X" + str(x_jerk)
|
||||
m205_jerk_new = f"X{x_jerk}"
|
||||
if x_jerk != 0 and y_jerk != 0:
|
||||
m205_jerk_pattern = "M205 X(\d*) Y(\d*)"
|
||||
m205_jerk_new = "M205 X" + str(x_jerk) + " Y" + str(y_jerk)
|
||||
m205_jerk_old = "M205 X" + str(jerk_old) + " Y" + str(jerk_old)
|
||||
m205_jerk_pattern = jerk_cmd + " X(\d*) Y(\d*)"
|
||||
m205_jerk_new = jerk_cmd + f" X{x_jerk} Y{y_jerk}"
|
||||
m205_jerk_old = jerk_cmd + f" X{jerk_old} Y{jerk_old}"
|
||||
type_of_change = self.getSettingValueByKey("type_of_change")
|
||||
|
||||
#Get the indexes of the start and end layers----------------------------------------
|
||||
|
@ -245,7 +268,7 @@ class LimitXYAccelJerk(Script):
|
|||
layer = data[num]
|
||||
lines = layer.split("\n")
|
||||
for index, line in enumerate(lines):
|
||||
if line.startswith("M205"):
|
||||
if line.startswith("M205") or line.startswith("M566"):
|
||||
lines[index] = re.sub(m205_jerk_pattern, m205_jerk_new, line)
|
||||
data[num] = "\n".join(lines)
|
||||
if end_layer != -1:
|
||||
|
@ -319,7 +342,7 @@ class LimitXYAccelJerk(Script):
|
|||
layer = data[num]
|
||||
lines = layer.split("\n")
|
||||
for index, line in enumerate(lines):
|
||||
if line.startswith("M205"):
|
||||
if line.startswith("M205") or line.startswith("M566"):
|
||||
lines[index] = re.sub(m205_jerk_pattern, m205_jerk_new, line)
|
||||
data[num] = "\n".join(lines)
|
||||
data[len(data)-1] = m201_limit_old + "\n" + m205_jerk_old + "\n" + data[len(data)-1]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue