mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Code style: Fields have lower camel casing
As specified in the Ultimaker/Meta repository.
This commit is contained in:
parent
9145a7e9e6
commit
74b9771c7d
1 changed files with 146 additions and 146 deletions
|
@ -336,7 +336,7 @@ class ChangeAtZ(Script):
|
||||||
|
|
||||||
caz_instance = ChangeAtZProcessor()
|
caz_instance = ChangeAtZProcessor()
|
||||||
|
|
||||||
caz_instance.TargetValues = {}
|
caz_instance.targetValues = {}
|
||||||
|
|
||||||
# copy over our settings to our change z class
|
# copy over our settings to our change z class
|
||||||
self.setIntSettingIfEnabled(caz_instance, "e1_Change_speed", "speed", "e2_speed")
|
self.setIntSettingIfEnabled(caz_instance, "e1_Change_speed", "speed", "e2_speed")
|
||||||
|
@ -352,23 +352,23 @@ class ChangeAtZ(Script):
|
||||||
self.setFloatSettingIfEnabled(caz_instance, "caz_change_retractlength", "retractlength", "caz_retractlength")
|
self.setFloatSettingIfEnabled(caz_instance, "caz_change_retractlength", "retractlength", "caz_retractlength")
|
||||||
|
|
||||||
# is this mod enabled?
|
# is this mod enabled?
|
||||||
caz_instance.IsEnabled = self.getSettingValueByKey("caz_enabled")
|
caz_instance.enabled = self.getSettingValueByKey("caz_enabled")
|
||||||
|
|
||||||
# are we emitting data to the LCD?
|
# are we emitting data to the LCD?
|
||||||
caz_instance.IsDisplayingChangesToLcd = self.getSettingValueByKey("caz_output_to_display")
|
caz_instance.displayChangesToLcd = self.getSettingValueByKey("caz_output_to_display")
|
||||||
|
|
||||||
# are we doing linear move retractions?
|
# are we doing linear move retractions?
|
||||||
caz_instance.IsLinearRetraction = self.getSettingValueByKey("caz_retractstyle") == "linear"
|
caz_instance.linearRetraction = self.getSettingValueByKey("caz_retractstyle") == "linear"
|
||||||
|
|
||||||
# see if we're applying to a single layer or to all layers hence forth
|
# see if we're applying to a single layer or to all layers hence forth
|
||||||
caz_instance.IsApplyToSingleLayer = self.getSettingValueByKey("c_behavior") == "single_layer"
|
caz_instance.applyToSingleLayer = self.getSettingValueByKey("c_behavior") == "single_layer"
|
||||||
|
|
||||||
# used for easy reference of layer or height targeting
|
# used for easy reference of layer or height targeting
|
||||||
caz_instance.IsTargetByLayer = self.getSettingValueByKey("a_trigger") == "layer_no"
|
caz_instance.targetByLayer = self.getSettingValueByKey("a_trigger") == "layer_no"
|
||||||
|
|
||||||
# change our target based on what we're targeting
|
# change our target based on what we're targeting
|
||||||
caz_instance.TargetLayer = self.getIntSettingByKey("b_targetL", None)
|
caz_instance.targetLayer = self.getIntSettingByKey("b_targetL", None)
|
||||||
caz_instance.TargetZ = self.getFloatSettingByKey("b_targetZ", None)
|
caz_instance.targetZ = self.getFloatSettingByKey("b_targetZ", None)
|
||||||
|
|
||||||
# run our script
|
# run our script
|
||||||
return caz_instance.execute(data)
|
return caz_instance.execute(data)
|
||||||
|
@ -388,7 +388,7 @@ class ChangeAtZ(Script):
|
||||||
return
|
return
|
||||||
|
|
||||||
# set our value in the target settings
|
# set our value in the target settings
|
||||||
caz_instance.TargetValues[target] = value
|
caz_instance.targetValues[target] = value
|
||||||
|
|
||||||
# Sets the given TargetValue in the ChangeAtZ instance if the trigger is specified
|
# Sets the given TargetValue in the ChangeAtZ instance if the trigger is specified
|
||||||
def setFloatSettingIfEnabled(self, caz_instance, trigger, target, setting):
|
def setFloatSettingIfEnabled(self, caz_instance, trigger, target, setting):
|
||||||
|
@ -405,7 +405,7 @@ class ChangeAtZ(Script):
|
||||||
return
|
return
|
||||||
|
|
||||||
# set our value in the target settings
|
# set our value in the target settings
|
||||||
caz_instance.TargetValues[target] = value
|
caz_instance.targetValues[target] = value
|
||||||
|
|
||||||
# Returns the given settings value as an integer or the default if it cannot parse it
|
# Returns the given settings value as an integer or the default if it cannot parse it
|
||||||
def getIntSettingByKey(self, key, default):
|
def getIntSettingByKey(self, key, default):
|
||||||
|
@ -430,13 +430,13 @@ class ChangeAtZ(Script):
|
||||||
class GCodeCommand:
|
class GCodeCommand:
|
||||||
|
|
||||||
# The GCode command itself (ex: G10)
|
# The GCode command itself (ex: G10)
|
||||||
Command = None,
|
command = None,
|
||||||
|
|
||||||
# Contains any arguments passed to the command. The key is the argument name, the value is the value of the argument.
|
# Contains any arguments passed to the command. The key is the argument name, the value is the value of the argument.
|
||||||
Arguments = {}
|
arguments = {}
|
||||||
|
|
||||||
# Contains the components of the command broken into pieces
|
# Contains the components of the command broken into pieces
|
||||||
Components = []
|
components = []
|
||||||
|
|
||||||
# Constructor. Sets up defaults
|
# Constructor. Sets up defaults
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -468,10 +468,10 @@ class GCodeCommand:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# stores all the components of the command within the class for later
|
# stores all the components of the command within the class for later
|
||||||
command.Components = command_pieces
|
command.components = command_pieces
|
||||||
|
|
||||||
# set the actual command
|
# set the actual command
|
||||||
command.Command = command_pieces[0]
|
command.command = command_pieces[0]
|
||||||
|
|
||||||
# stop here if we don't have any parameters
|
# stop here if we don't have any parameters
|
||||||
if len(command_pieces) == 1:
|
if len(command_pieces) == 1:
|
||||||
|
@ -488,15 +488,15 @@ class GCodeCommand:
|
||||||
linear_command = GCodeCommand.getFromLine(line)
|
linear_command = GCodeCommand.getFromLine(line)
|
||||||
|
|
||||||
# if it's not a linear move, we don't care
|
# if it's not a linear move, we don't care
|
||||||
if linear_command is None or (linear_command.Command != "G0" and linear_command.Command != "G1"):
|
if linear_command is None or (linear_command.command != "G0" and linear_command.command != "G1"):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# convert our values to floats (or defaults)
|
# convert our values to floats (or defaults)
|
||||||
linear_command.Arguments["F"] = linear_command.getArgumentAsFloat("F", None)
|
linear_command.arguments["F"] = linear_command.getArgumentAsFloat("F", None)
|
||||||
linear_command.Arguments["X"] = linear_command.getArgumentAsFloat("X", None)
|
linear_command.arguments["X"] = linear_command.getArgumentAsFloat("X", None)
|
||||||
linear_command.Arguments["Y"] = linear_command.getArgumentAsFloat("Y", None)
|
linear_command.arguments["Y"] = linear_command.getArgumentAsFloat("Y", None)
|
||||||
linear_command.Arguments["Z"] = linear_command.getArgumentAsFloat("Z", None)
|
linear_command.arguments["Z"] = linear_command.getArgumentAsFloat("Z", None)
|
||||||
linear_command.Arguments["E"] = linear_command.getArgumentAsFloat("E", None)
|
linear_command.arguments["E"] = linear_command.getArgumentAsFloat("E", None)
|
||||||
|
|
||||||
# return our new command
|
# return our new command
|
||||||
return linear_command
|
return linear_command
|
||||||
|
@ -508,11 +508,11 @@ class GCodeCommand:
|
||||||
self.parseArguments()
|
self.parseArguments()
|
||||||
|
|
||||||
# if we don't have the parameter, return the default
|
# if we don't have the parameter, return the default
|
||||||
if name not in self.Arguments:
|
if name not in self.arguments:
|
||||||
return default
|
return default
|
||||||
|
|
||||||
# otherwise return the value
|
# otherwise return the value
|
||||||
return self.Arguments[name]
|
return self.arguments[name]
|
||||||
|
|
||||||
# Gets the value of a parameter as a float or returns the default
|
# Gets the value of a parameter as a float or returns the default
|
||||||
def getArgumentAsFloat(self, name: str, default: float = None) -> float:
|
def getArgumentAsFloat(self, name: str, default: float = None) -> float:
|
||||||
|
@ -593,14 +593,14 @@ class GCodeCommand:
|
||||||
def parseArguments(self):
|
def parseArguments(self):
|
||||||
|
|
||||||
# stop here if we don't have any remaining components
|
# stop here if we don't have any remaining components
|
||||||
if len(self.Components) <= 1:
|
if len(self.components) <= 1:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# iterate and index all of our parameters, skip the first component as it's the command
|
# iterate and index all of our parameters, skip the first component as it's the command
|
||||||
for i in range(1, len(self.Components)):
|
for i in range(1, len(self.components)):
|
||||||
|
|
||||||
# get our component
|
# get our component
|
||||||
component = self.Components[i]
|
component = self.components[i]
|
||||||
|
|
||||||
# get the first character of the parameter, which is the name
|
# get the first character of the parameter, which is the name
|
||||||
component_name = component[0]
|
component_name = component[0]
|
||||||
|
@ -613,10 +613,10 @@ class GCodeCommand:
|
||||||
component_value = component[1:]
|
component_value = component[1:]
|
||||||
|
|
||||||
# index the argument
|
# index the argument
|
||||||
self.Arguments[component_name] = component_value
|
self.arguments[component_name] = component_value
|
||||||
|
|
||||||
# clear the components to we don't process again
|
# clear the components to we don't process again
|
||||||
self.Components = []
|
self.components = []
|
||||||
|
|
||||||
# Easy function for replacing any GCODE parameter variable in a given GCODE command
|
# Easy function for replacing any GCODE parameter variable in a given GCODE command
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -625,8 +625,8 @@ class GCodeCommand:
|
||||||
|
|
||||||
# Resets the model back to defaults
|
# Resets the model back to defaults
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.Command = None
|
self.command = None
|
||||||
self.Arguments = {}
|
self.arguments = {}
|
||||||
|
|
||||||
|
|
||||||
# The primary ChangeAtZ class that does all the gcode editing. This was broken out into an
|
# The primary ChangeAtZ class that does all the gcode editing. This was broken out into an
|
||||||
|
@ -634,55 +634,55 @@ class GCodeCommand:
|
||||||
class ChangeAtZProcessor:
|
class ChangeAtZProcessor:
|
||||||
|
|
||||||
# Holds our current height
|
# Holds our current height
|
||||||
CurrentZ = None
|
currentZ = None
|
||||||
|
|
||||||
# Holds our current layer number
|
# Holds our current layer number
|
||||||
CurrentLayer = None
|
currentLayer = None
|
||||||
|
|
||||||
# Indicates if we're only supposed to apply our settings to a single layer or multiple layers
|
# Indicates if we're only supposed to apply our settings to a single layer or multiple layers
|
||||||
IsApplyToSingleLayer = False
|
applyToSingleLayer = False
|
||||||
|
|
||||||
# Indicates if this should emit the changes as they happen to the LCD
|
# Indicates if this should emit the changes as they happen to the LCD
|
||||||
IsDisplayingChangesToLcd = False
|
displayChangesToLcd = False
|
||||||
|
|
||||||
# Indicates that this mod is still enabled (or not)
|
# Indicates that this mod is still enabled (or not)
|
||||||
IsEnabled = True
|
enabled = True
|
||||||
|
|
||||||
# Indicates if we're processing inside the target layer or not
|
# Indicates if we're processing inside the target layer or not
|
||||||
IsInsideTargetLayer = False
|
insideTargetLayer = False
|
||||||
|
|
||||||
# Indicates if we have restored the previous values from before we started our pass
|
# Indicates if we have restored the previous values from before we started our pass
|
||||||
IsLastValuesRestored = False
|
lastValuesRestored = False
|
||||||
|
|
||||||
# Indicates if the user has opted for linear move retractions or firmware retractions
|
# Indicates if the user has opted for linear move retractions or firmware retractions
|
||||||
IsLinearRetraction = True
|
linearRetraction = True
|
||||||
|
|
||||||
# Indicates if we're targetting by layer or height value
|
# Indicates if we're targetting by layer or height value
|
||||||
IsTargetByLayer = True
|
targetByLayer = True
|
||||||
|
|
||||||
# Indicates if we have injected our changed values for the given layer yet
|
# Indicates if we have injected our changed values for the given layer yet
|
||||||
IsTargetValuesInjected = False
|
targetValuesInjected = False
|
||||||
|
|
||||||
# Holds the last extrusion value, used with detecting when a retraction is made
|
# Holds the last extrusion value, used with detecting when a retraction is made
|
||||||
LastE = None
|
lastE = None
|
||||||
|
|
||||||
# An index of our gcodes which we're monitoring
|
# An index of our gcodes which we're monitoring
|
||||||
LastValues = {}
|
lastValues = {}
|
||||||
|
|
||||||
# The detected layer height from the gcode
|
# The detected layer height from the gcode
|
||||||
LayerHeight = None
|
layerHeight = None
|
||||||
|
|
||||||
# The target layer
|
# The target layer
|
||||||
TargetLayer = None
|
targetLayer = None
|
||||||
|
|
||||||
# Holds the values the user has requested to change
|
# Holds the values the user has requested to change
|
||||||
TargetValues = {}
|
targetValues = {}
|
||||||
|
|
||||||
# The target height in mm
|
# The target height in mm
|
||||||
TargetZ = None
|
targetZ = None
|
||||||
|
|
||||||
# Used to track if we've been inside our target layer yet
|
# Used to track if we've been inside our target layer yet
|
||||||
WasInsideTargetLayer = False
|
wasInsideTargetLayer = False
|
||||||
|
|
||||||
# boots up the class with defaults
|
# boots up the class with defaults
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -692,7 +692,7 @@ class ChangeAtZProcessor:
|
||||||
def execute(self, data):
|
def execute(self, data):
|
||||||
|
|
||||||
# short cut the whole thing if we're not enabled
|
# short cut the whole thing if we're not enabled
|
||||||
if not self.IsEnabled:
|
if not self.enabled:
|
||||||
return data
|
return data
|
||||||
|
|
||||||
# our layer cursor
|
# our layer cursor
|
||||||
|
@ -750,14 +750,14 @@ class ChangeAtZProcessor:
|
||||||
|
|
||||||
# for each of our target values, get the value to restore
|
# for each of our target values, get the value to restore
|
||||||
# no point in restoring values we haven't changed
|
# no point in restoring values we haven't changed
|
||||||
for key in self.TargetValues:
|
for key in self.targetValues:
|
||||||
|
|
||||||
# skip target values we can't restore
|
# skip target values we can't restore
|
||||||
if key not in self.LastValues:
|
if key not in self.lastValues:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# save into our changed
|
# save into our changed
|
||||||
changed[key] = self.LastValues[key]
|
changed[key] = self.lastValues[key]
|
||||||
|
|
||||||
# return our collection of changed values
|
# return our collection of changed values
|
||||||
return changed
|
return changed
|
||||||
|
@ -766,7 +766,7 @@ class ChangeAtZProcessor:
|
||||||
def getDisplayChangesFromValues(self, values: Dict[str, any]) -> str:
|
def getDisplayChangesFromValues(self, values: Dict[str, any]) -> str:
|
||||||
|
|
||||||
# stop here if we're not outputting data
|
# stop here if we're not outputting data
|
||||||
if not self.IsDisplayingChangesToLcd:
|
if not self.displayChangesToLcd:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
# will hold all the default settings for the target layer
|
# will hold all the default settings for the target layer
|
||||||
|
@ -833,7 +833,7 @@ class ChangeAtZProcessor:
|
||||||
def getTargetDisplayValues(self) -> str:
|
def getTargetDisplayValues(self) -> str:
|
||||||
|
|
||||||
# convert our target values to something we can output
|
# convert our target values to something we can output
|
||||||
return self.getDisplayChangesFromValues(self.TargetValues)
|
return self.getDisplayChangesFromValues(self.targetValues)
|
||||||
|
|
||||||
# Builds the the relevant GCODE lines from the given collection of values
|
# Builds the the relevant GCODE lines from the given collection of values
|
||||||
def getCodeFromValues(self, values: Dict[str, any]) -> str:
|
def getCodeFromValues(self, values: Dict[str, any]) -> str:
|
||||||
|
@ -898,7 +898,7 @@ class ChangeAtZProcessor:
|
||||||
# set retract rate
|
# set retract rate
|
||||||
if "retractfeedrate" in values:
|
if "retractfeedrate" in values:
|
||||||
|
|
||||||
if self.IsLinearRetraction:
|
if self.linearRetraction:
|
||||||
codes.append(";RETRACTFEEDRATE " + str(values["retractfeedrate"] * 60) + "")
|
codes.append(";RETRACTFEEDRATE " + str(values["retractfeedrate"] * 60) + "")
|
||||||
else:
|
else:
|
||||||
codes.append("M207 F" + str(values["retractfeedrate"] * 60) + "")
|
codes.append("M207 F" + str(values["retractfeedrate"] * 60) + "")
|
||||||
|
@ -906,7 +906,7 @@ class ChangeAtZProcessor:
|
||||||
# set retract length
|
# set retract length
|
||||||
if "retractlength" in values:
|
if "retractlength" in values:
|
||||||
|
|
||||||
if self.IsLinearRetraction:
|
if self.linearRetraction:
|
||||||
codes.append(";RETRACTLENGTH " + str(values["retractlength"]) + "")
|
codes.append(";RETRACTLENGTH " + str(values["retractlength"]) + "")
|
||||||
else:
|
else:
|
||||||
codes.append("M207 S" + str(values["retractlength"]) + "")
|
codes.append("M207 S" + str(values["retractlength"]) + "")
|
||||||
|
@ -923,19 +923,19 @@ class ChangeAtZProcessor:
|
||||||
def getInjectCode(self) -> str:
|
def getInjectCode(self) -> str:
|
||||||
|
|
||||||
# if we're now outside of our target layer and haven't restored our last values, do so now
|
# if we're now outside of our target layer and haven't restored our last values, do so now
|
||||||
if not self.IsInsideTargetLayer and self.WasInsideTargetLayer and not self.IsLastValuesRestored:
|
if not self.insideTargetLayer and self.wasInsideTargetLayer and not self.lastValuesRestored:
|
||||||
|
|
||||||
# mark that we've injected the last values
|
# mark that we've injected the last values
|
||||||
self.IsLastValuesRestored = True
|
self.lastValuesRestored = True
|
||||||
|
|
||||||
# inject the defaults
|
# inject the defaults
|
||||||
return self.getLastValues() + "\n" + self.getLastDisplayValues()
|
return self.getLastValues() + "\n" + self.getLastDisplayValues()
|
||||||
|
|
||||||
# if we're inside our target layer but haven't added our values yet, do so now
|
# if we're inside our target layer but haven't added our values yet, do so now
|
||||||
if self.IsInsideTargetLayer and not self.IsTargetValuesInjected:
|
if self.insideTargetLayer and not self.targetValuesInjected:
|
||||||
|
|
||||||
# mark that we've injected the target values
|
# mark that we've injected the target values
|
||||||
self.IsTargetValuesInjected = True
|
self.targetValuesInjected = True
|
||||||
|
|
||||||
# inject the defaults
|
# inject the defaults
|
||||||
return self.getTargetValues() + "\n" + self.getTargetDisplayValues()
|
return self.getTargetValues() + "\n" + self.getTargetDisplayValues()
|
||||||
|
@ -960,35 +960,35 @@ class ChangeAtZProcessor:
|
||||||
def getTargetValues(self) -> str:
|
def getTargetValues(self) -> str:
|
||||||
|
|
||||||
# build the gcode to change our current values
|
# build the gcode to change our current values
|
||||||
return self.getCodeFromValues(self.TargetValues)
|
return self.getCodeFromValues(self.targetValues)
|
||||||
|
|
||||||
# Determines if the current line is at or below the target required to start modifying
|
# Determines if the current line is at or below the target required to start modifying
|
||||||
def isTargetLayerOrHeight(self) -> bool:
|
def isTargetLayerOrHeight(self) -> bool:
|
||||||
|
|
||||||
# target selected by layer no.
|
# target selected by layer no.
|
||||||
if self.IsTargetByLayer:
|
if self.targetByLayer:
|
||||||
|
|
||||||
# if we don't have a current layer, we're not there yet
|
# if we don't have a current layer, we're not there yet
|
||||||
if self.CurrentLayer is None:
|
if self.currentLayer is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# if we're applying to a single layer, stop if our layer is not identical
|
# if we're applying to a single layer, stop if our layer is not identical
|
||||||
if self.IsApplyToSingleLayer:
|
if self.applyToSingleLayer:
|
||||||
return self.CurrentLayer == self.TargetLayer
|
return self.currentLayer == self.targetLayer
|
||||||
else:
|
else:
|
||||||
return self.CurrentLayer >= self.TargetLayer
|
return self.currentLayer >= self.targetLayer
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
# if we don't have a current Z, we're not there yet
|
# if we don't have a current Z, we're not there yet
|
||||||
if self.CurrentZ is None:
|
if self.currentZ is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# if we're applying to a single layer, stop if our Z is not identical
|
# if we're applying to a single layer, stop if our Z is not identical
|
||||||
if self.IsApplyToSingleLayer:
|
if self.applyToSingleLayer:
|
||||||
return self.CurrentZ == self.TargetZ
|
return self.currentZ == self.targetZ
|
||||||
else:
|
else:
|
||||||
return self.CurrentZ >= self.TargetZ
|
return self.currentZ >= self.targetZ
|
||||||
|
|
||||||
# Marks any current ChangeZ layer defaults in the layer for deletion
|
# Marks any current ChangeZ layer defaults in the layer for deletion
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -999,7 +999,7 @@ class ChangeAtZProcessor:
|
||||||
def processLayerHeight(self, line: str):
|
def processLayerHeight(self, line: str):
|
||||||
|
|
||||||
# stop here if we haven't entered a layer yet
|
# stop here if we haven't entered a layer yet
|
||||||
if self.CurrentLayer is None:
|
if self.currentLayer is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
# get our gcode command
|
# get our gcode command
|
||||||
|
@ -1010,7 +1010,7 @@ class ChangeAtZProcessor:
|
||||||
return
|
return
|
||||||
|
|
||||||
# stop here if this isn't a linear move command
|
# stop here if this isn't a linear move command
|
||||||
if command.Command != "G0" and command.Command != "G1":
|
if command.command != "G0" and command.command != "G1":
|
||||||
return
|
return
|
||||||
|
|
||||||
# get our value from the command
|
# get our value from the command
|
||||||
|
@ -1021,15 +1021,15 @@ class ChangeAtZProcessor:
|
||||||
return
|
return
|
||||||
|
|
||||||
# stop if there's no change
|
# stop if there's no change
|
||||||
if current_z == self.CurrentZ:
|
if current_z == self.currentZ:
|
||||||
return
|
return
|
||||||
|
|
||||||
# set our current Z value
|
# set our current Z value
|
||||||
self.CurrentZ = current_z
|
self.currentZ = current_z
|
||||||
|
|
||||||
# if we don't have a layer height yet, set it based on the current Z value
|
# if we don't have a layer height yet, set it based on the current Z value
|
||||||
if self.LayerHeight is None:
|
if self.layerHeight is None:
|
||||||
self.LayerHeight = self.CurrentZ
|
self.layerHeight = self.currentZ
|
||||||
|
|
||||||
# Grabs the current layer number
|
# Grabs the current layer number
|
||||||
def processLayerNumber(self, line: str):
|
def processLayerNumber(self, line: str):
|
||||||
|
@ -1042,11 +1042,11 @@ class ChangeAtZProcessor:
|
||||||
current_layer = GCodeCommand.getDirectArgumentAsInt(line, ";LAYER:", None)
|
current_layer = GCodeCommand.getDirectArgumentAsInt(line, ";LAYER:", None)
|
||||||
|
|
||||||
# this should never happen, but if our layer number hasn't changed, stop here
|
# this should never happen, but if our layer number hasn't changed, stop here
|
||||||
if current_layer == self.CurrentLayer:
|
if current_layer == self.currentLayer:
|
||||||
return
|
return
|
||||||
|
|
||||||
# update our current layer
|
# update our current layer
|
||||||
self.CurrentLayer = current_layer
|
self.currentLayer = current_layer
|
||||||
|
|
||||||
# Makes any linear move changes and also injects either target or restored values depending on the plugin state
|
# Makes any linear move changes and also injects either target or restored values depending on the plugin state
|
||||||
def processLine(self, line: str) -> str:
|
def processLine(self, line: str) -> str:
|
||||||
|
@ -1059,10 +1059,10 @@ class ChangeAtZProcessor:
|
||||||
|
|
||||||
# if we're not inside the target layer, simply read the any
|
# if we're not inside the target layer, simply read the any
|
||||||
# settings we can and revert any ChangeAtZ deletions
|
# settings we can and revert any ChangeAtZ deletions
|
||||||
if not self.IsInsideTargetLayer:
|
if not self.insideTargetLayer:
|
||||||
|
|
||||||
# read any settings if we haven't hit our target layer yet
|
# read any settings if we haven't hit our target layer yet
|
||||||
if not self.WasInsideTargetLayer:
|
if not self.wasInsideTargetLayer:
|
||||||
self.processSetting(line)
|
self.processSetting(line)
|
||||||
|
|
||||||
# if we haven't hit our target yet, leave the defaults as is (unmark them for deletion)
|
# if we haven't hit our target yet, leave the defaults as is (unmark them for deletion)
|
||||||
|
@ -1074,7 +1074,7 @@ class ChangeAtZProcessor:
|
||||||
modified_gcode += self.getInjectCode()
|
modified_gcode += self.getInjectCode()
|
||||||
|
|
||||||
# modify our command if we're still inside our target layer, otherwise pass unmodified
|
# modify our command if we're still inside our target layer, otherwise pass unmodified
|
||||||
if self.IsInsideTargetLayer:
|
if self.insideTargetLayer:
|
||||||
modified_gcode += self.processLinearMove(line) + "\n"
|
modified_gcode += self.processLinearMove(line) + "\n"
|
||||||
else:
|
else:
|
||||||
modified_gcode += line + "\n"
|
modified_gcode += line + "\n"
|
||||||
|
@ -1104,11 +1104,11 @@ class ChangeAtZProcessor:
|
||||||
return line
|
return line
|
||||||
|
|
||||||
# get our linear move parameters
|
# get our linear move parameters
|
||||||
feed_rate = linear_command.Arguments["F"]
|
feed_rate = linear_command.arguments["F"]
|
||||||
x_coord = linear_command.Arguments["X"]
|
x_coord = linear_command.arguments["X"]
|
||||||
y_coord = linear_command.Arguments["Y"]
|
y_coord = linear_command.arguments["Y"]
|
||||||
z_coord = linear_command.Arguments["Z"]
|
z_coord = linear_command.arguments["Z"]
|
||||||
extrude_length = linear_command.Arguments["E"]
|
extrude_length = linear_command.arguments["E"]
|
||||||
|
|
||||||
# set our new line to our old line
|
# set our new line to our old line
|
||||||
new_line = line
|
new_line = line
|
||||||
|
@ -1124,7 +1124,7 @@ class ChangeAtZProcessor:
|
||||||
new_line = self.processPrintSpeed(feed_rate, new_line)
|
new_line = self.processPrintSpeed(feed_rate, new_line)
|
||||||
|
|
||||||
# set our current extrude position
|
# set our current extrude position
|
||||||
self.LastE = extrude_length if extrude_length is not None else self.LastE
|
self.lastE = extrude_length if extrude_length is not None else self.lastE
|
||||||
|
|
||||||
# if no changes have been made, stop here
|
# if no changes have been made, stop here
|
||||||
if new_line == line:
|
if new_line == line:
|
||||||
|
@ -1137,11 +1137,11 @@ class ChangeAtZProcessor:
|
||||||
def processPrintSpeed(self, feed_rate: float, new_line: str) -> str:
|
def processPrintSpeed(self, feed_rate: float, new_line: str) -> str:
|
||||||
|
|
||||||
# if we're not setting print speed or we don't have a feed rate, stop here
|
# if we're not setting print speed or we don't have a feed rate, stop here
|
||||||
if "printspeed" not in self.TargetValues or feed_rate is None:
|
if "printspeed" not in self.targetValues or feed_rate is None:
|
||||||
return new_line
|
return new_line
|
||||||
|
|
||||||
# get our requested print speed
|
# get our requested print speed
|
||||||
print_speed = int(self.TargetValues["printspeed"])
|
print_speed = int(self.targetValues["printspeed"])
|
||||||
|
|
||||||
# if they requested no change to print speed (ie: 100%), stop here
|
# if they requested no change to print speed (ie: 100%), stop here
|
||||||
if print_speed == 100:
|
if print_speed == 100:
|
||||||
|
@ -1157,11 +1157,11 @@ class ChangeAtZProcessor:
|
||||||
def processRetractLength(self, extrude_length: float, feed_rate: float, new_line: str, x_coord: float, y_coord: float, z_coord: float) -> str:
|
def processRetractLength(self, extrude_length: float, feed_rate: float, new_line: str, x_coord: float, y_coord: float, z_coord: float) -> str:
|
||||||
|
|
||||||
# if we don't have a retract length in the file we can't add one
|
# if we don't have a retract length in the file we can't add one
|
||||||
if "retractlength" not in self.LastValues or self.LastValues["retractlength"] == 0:
|
if "retractlength" not in self.lastValues or self.lastValues["retractlength"] == 0:
|
||||||
return new_line
|
return new_line
|
||||||
|
|
||||||
# if we're not changing retraction length, stop here
|
# if we're not changing retraction length, stop here
|
||||||
if "retractlength" not in self.TargetValues:
|
if "retractlength" not in self.targetValues:
|
||||||
return new_line
|
return new_line
|
||||||
|
|
||||||
# retractions are only F (feed rate) and E (extrude), at least in cura
|
# retractions are only F (feed rate) and E (extrude), at least in cura
|
||||||
|
@ -1173,22 +1173,22 @@ class ChangeAtZProcessor:
|
||||||
return new_line
|
return new_line
|
||||||
|
|
||||||
# stop here if we don't know our last extrude value
|
# stop here if we don't know our last extrude value
|
||||||
if self.LastE is None:
|
if self.lastE is None:
|
||||||
return new_line
|
return new_line
|
||||||
|
|
||||||
# if there's no change in extrude we have nothing to change
|
# if there's no change in extrude we have nothing to change
|
||||||
if self.LastE == extrude_length:
|
if self.lastE == extrude_length:
|
||||||
return new_line
|
return new_line
|
||||||
|
|
||||||
# if our last extrude was lower than our current, we're restoring, so skip
|
# if our last extrude was lower than our current, we're restoring, so skip
|
||||||
if self.LastE < extrude_length:
|
if self.lastE < extrude_length:
|
||||||
return new_line
|
return new_line
|
||||||
|
|
||||||
# get our desired retract length
|
# get our desired retract length
|
||||||
retract_length = float(self.TargetValues["retractlength"])
|
retract_length = float(self.targetValues["retractlength"])
|
||||||
|
|
||||||
# subtract the difference between the default and the desired
|
# subtract the difference between the default and the desired
|
||||||
extrude_length -= (retract_length - self.LastValues["retractlength"])
|
extrude_length -= (retract_length - self.lastValues["retractlength"])
|
||||||
|
|
||||||
# replace our extrude amount
|
# replace our extrude amount
|
||||||
return GCodeCommand.replaceDirectArgument(new_line, "E", extrude_length)
|
return GCodeCommand.replaceDirectArgument(new_line, "E", extrude_length)
|
||||||
|
@ -1197,7 +1197,7 @@ class ChangeAtZProcessor:
|
||||||
def processRetractLengthSetting(self, line: str):
|
def processRetractLengthSetting(self, line: str):
|
||||||
|
|
||||||
# skip if we're not doing linear retractions
|
# skip if we're not doing linear retractions
|
||||||
if not self.IsLinearRetraction:
|
if not self.linearRetraction:
|
||||||
return
|
return
|
||||||
|
|
||||||
# get our command from the line
|
# get our command from the line
|
||||||
|
@ -1208,11 +1208,11 @@ class ChangeAtZProcessor:
|
||||||
return
|
return
|
||||||
|
|
||||||
# get our linear move parameters
|
# get our linear move parameters
|
||||||
feed_rate = linear_command.Arguments["F"]
|
feed_rate = linear_command.arguments["F"]
|
||||||
x_coord = linear_command.Arguments["X"]
|
x_coord = linear_command.arguments["X"]
|
||||||
y_coord = linear_command.Arguments["Y"]
|
y_coord = linear_command.arguments["Y"]
|
||||||
z_coord = linear_command.Arguments["Z"]
|
z_coord = linear_command.arguments["Z"]
|
||||||
extrude_length = linear_command.Arguments["E"]
|
extrude_length = linear_command.arguments["E"]
|
||||||
|
|
||||||
# the command we're looking for only has extrude and feed rate
|
# the command we're looking for only has extrude and feed rate
|
||||||
if x_coord is not None or y_coord is not None or z_coord is not None:
|
if x_coord is not None or y_coord is not None or z_coord is not None:
|
||||||
|
@ -1230,17 +1230,17 @@ class ChangeAtZProcessor:
|
||||||
return
|
return
|
||||||
|
|
||||||
# what ever the last negative retract length is it wins
|
# what ever the last negative retract length is it wins
|
||||||
self.LastValues["retractlength"] = extrude_length
|
self.lastValues["retractlength"] = extrude_length
|
||||||
|
|
||||||
# Handles any changes to retraction feed rate for the given linear motion command
|
# Handles any changes to retraction feed rate for the given linear motion command
|
||||||
def processRetractFeedRate(self, extrude_length: float, feed_rate: float, new_line: str, x_coord: float, y_coord: float, z_coord: float) -> str:
|
def processRetractFeedRate(self, extrude_length: float, feed_rate: float, new_line: str, x_coord: float, y_coord: float, z_coord: float) -> str:
|
||||||
|
|
||||||
# skip if we're not doing linear retractions
|
# skip if we're not doing linear retractions
|
||||||
if not self.IsLinearRetraction:
|
if not self.linearRetraction:
|
||||||
return new_line
|
return new_line
|
||||||
|
|
||||||
# if we're not changing retraction length, stop here
|
# if we're not changing retraction length, stop here
|
||||||
if "retractfeedrate" not in self.TargetValues:
|
if "retractfeedrate" not in self.targetValues:
|
||||||
return new_line
|
return new_line
|
||||||
|
|
||||||
# retractions are only F (feed rate) and E (extrude), at least in cura
|
# retractions are only F (feed rate) and E (extrude), at least in cura
|
||||||
|
@ -1252,7 +1252,7 @@ class ChangeAtZProcessor:
|
||||||
return new_line
|
return new_line
|
||||||
|
|
||||||
# get our desired retract feed rate
|
# get our desired retract feed rate
|
||||||
retract_feed_rate = float(self.TargetValues["retractfeedrate"])
|
retract_feed_rate = float(self.targetValues["retractfeedrate"])
|
||||||
|
|
||||||
# convert to units/min
|
# convert to units/min
|
||||||
retract_feed_rate *= 60
|
retract_feed_rate *= 60
|
||||||
|
@ -1264,7 +1264,7 @@ class ChangeAtZProcessor:
|
||||||
def processSetting(self, line: str):
|
def processSetting(self, line: str):
|
||||||
|
|
||||||
# if we're in layers already we're out of settings
|
# if we're in layers already we're out of settings
|
||||||
if self.CurrentLayer is not None:
|
if self.currentLayer is not None:
|
||||||
return
|
return
|
||||||
|
|
||||||
# check our retract length
|
# check our retract length
|
||||||
|
@ -1277,16 +1277,16 @@ class ChangeAtZProcessor:
|
||||||
if not self.isTargetLayerOrHeight():
|
if not self.isTargetLayerOrHeight():
|
||||||
|
|
||||||
# flag that we're outside our target layer
|
# flag that we're outside our target layer
|
||||||
self.IsInsideTargetLayer = False
|
self.insideTargetLayer = False
|
||||||
|
|
||||||
# skip to the next line
|
# skip to the next line
|
||||||
return
|
return
|
||||||
|
|
||||||
# flip if we hit our target layer
|
# flip if we hit our target layer
|
||||||
self.WasInsideTargetLayer = True
|
self.wasInsideTargetLayer = True
|
||||||
|
|
||||||
# flag that we're inside our target layer
|
# flag that we're inside our target layer
|
||||||
self.IsInsideTargetLayer = True
|
self.insideTargetLayer = True
|
||||||
|
|
||||||
# Removes all the ChangeZ layer defaults from the given layer
|
# Removes all the ChangeZ layer defaults from the given layer
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -1296,22 +1296,22 @@ class ChangeAtZProcessor:
|
||||||
# Resets the class contents to defaults
|
# Resets the class contents to defaults
|
||||||
def reset(self):
|
def reset(self):
|
||||||
|
|
||||||
self.TargetValues = {}
|
self.targetValues = {}
|
||||||
self.IsApplyToSingleLayer = False
|
self.applyToSingleLayer = False
|
||||||
self.LastE = None
|
self.lastE = None
|
||||||
self.CurrentZ = None
|
self.currentZ = None
|
||||||
self.CurrentLayer = None
|
self.currentLayer = None
|
||||||
self.IsTargetByLayer = True
|
self.targetByLayer = True
|
||||||
self.TargetLayer = None
|
self.targetLayer = None
|
||||||
self.TargetZ = None
|
self.targetZ = None
|
||||||
self.LayerHeight = None
|
self.layerHeight = None
|
||||||
self.LastValues = {}
|
self.lastValues = {}
|
||||||
self.IsLinearRetraction = True
|
self.linearRetraction = True
|
||||||
self.IsInsideTargetLayer = False
|
self.insideTargetLayer = False
|
||||||
self.IsTargetValuesInjected = False
|
self.targetValuesInjected = False
|
||||||
self.IsLastValuesRestored = False
|
self.lastValuesRestored = False
|
||||||
self.WasInsideTargetLayer = False
|
self.wasInsideTargetLayer = False
|
||||||
self.IsEnabled = True
|
self.enabled = True
|
||||||
|
|
||||||
# Sets the original GCODE line in a given GCODE command
|
# Sets the original GCODE line in a given GCODE command
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -1341,31 +1341,31 @@ class ChangeAtZProcessor:
|
||||||
return
|
return
|
||||||
|
|
||||||
# handle retract length changes
|
# handle retract length changes
|
||||||
if command.Command == "M207":
|
if command.command == "M207":
|
||||||
|
|
||||||
# get our retract length if provided
|
# get our retract length if provided
|
||||||
if "S" in command.Arguments:
|
if "S" in command.arguments:
|
||||||
self.LastValues["retractlength"] = command.getArgumentAsFloat("S")
|
self.lastValues["retractlength"] = command.getArgumentAsFloat("S")
|
||||||
|
|
||||||
# get our retract feedrate if provided, convert from mm/m to mm/s
|
# get our retract feedrate if provided, convert from mm/m to mm/s
|
||||||
if "F" in command.Arguments:
|
if "F" in command.arguments:
|
||||||
self.LastValues["retractfeedrate"] = command.getArgumentAsFloat("F") / 60.0
|
self.lastValues["retractfeedrate"] = command.getArgumentAsFloat("F") / 60.0
|
||||||
|
|
||||||
# move to the next command
|
# move to the next command
|
||||||
return
|
return
|
||||||
|
|
||||||
# handle bed temp changes
|
# handle bed temp changes
|
||||||
if command.Command == "M140" or command.Command == "M190":
|
if command.command == "M140" or command.command == "M190":
|
||||||
|
|
||||||
# get our bed temp if provided
|
# get our bed temp if provided
|
||||||
if "S" in command.Arguments:
|
if "S" in command.arguments:
|
||||||
self.LastValues["bedTemp"] = command.getArgumentAsFloat("S")
|
self.lastValues["bedTemp"] = command.getArgumentAsFloat("S")
|
||||||
|
|
||||||
# move to the next command
|
# move to the next command
|
||||||
return
|
return
|
||||||
|
|
||||||
# handle extruder temp changes
|
# handle extruder temp changes
|
||||||
if command.Command == "M104" or command.Command == "M109":
|
if command.command == "M104" or command.command == "M109":
|
||||||
|
|
||||||
# get our tempurature
|
# get our tempurature
|
||||||
tempurature = command.getArgumentAsFloat("S")
|
tempurature = command.getArgumentAsFloat("S")
|
||||||
|
@ -1379,26 +1379,26 @@ class ChangeAtZProcessor:
|
||||||
|
|
||||||
# set our extruder temp based on the extruder
|
# set our extruder temp based on the extruder
|
||||||
if extruder is None or extruder == 0:
|
if extruder is None or extruder == 0:
|
||||||
self.LastValues["extruderOne"] = tempurature
|
self.lastValues["extruderOne"] = tempurature
|
||||||
|
|
||||||
if extruder is None or extruder == 1:
|
if extruder is None or extruder == 1:
|
||||||
self.LastValues["extruderTwo"] = tempurature
|
self.lastValues["extruderTwo"] = tempurature
|
||||||
|
|
||||||
# move to the next command
|
# move to the next command
|
||||||
return
|
return
|
||||||
|
|
||||||
# handle fan speed changes
|
# handle fan speed changes
|
||||||
if command.Command == "M106":
|
if command.command == "M106":
|
||||||
|
|
||||||
# get our bed temp if provided
|
# get our bed temp if provided
|
||||||
if "S" in command.Arguments:
|
if "S" in command.arguments:
|
||||||
self.LastValues["fanSpeed"] = (command.getArgumentAsInt("S") / 255.0) * 100
|
self.lastValues["fanSpeed"] = (command.getArgumentAsInt("S") / 255.0) * 100
|
||||||
|
|
||||||
# move to the next command
|
# move to the next command
|
||||||
return
|
return
|
||||||
|
|
||||||
# handle flow rate changes
|
# handle flow rate changes
|
||||||
if command.Command == "M221":
|
if command.command == "M221":
|
||||||
|
|
||||||
# get our flow rate
|
# get our flow rate
|
||||||
tempurature = command.getArgumentAsFloat("S")
|
tempurature = command.getArgumentAsFloat("S")
|
||||||
|
@ -1412,21 +1412,21 @@ class ChangeAtZProcessor:
|
||||||
|
|
||||||
# set our extruder temp based on the extruder
|
# set our extruder temp based on the extruder
|
||||||
if extruder is None:
|
if extruder is None:
|
||||||
self.LastValues["flowrate"] = tempurature
|
self.lastValues["flowrate"] = tempurature
|
||||||
elif extruder == 1:
|
elif extruder == 1:
|
||||||
self.LastValues["flowrateOne"] = tempurature
|
self.lastValues["flowrateOne"] = tempurature
|
||||||
elif extruder == 1:
|
elif extruder == 1:
|
||||||
self.LastValues["flowrateTwo"] = tempurature
|
self.lastValues["flowrateTwo"] = tempurature
|
||||||
|
|
||||||
# move to the next command
|
# move to the next command
|
||||||
return
|
return
|
||||||
|
|
||||||
# handle print speed changes
|
# handle print speed changes
|
||||||
if command.Command == "M220":
|
if command.command == "M220":
|
||||||
|
|
||||||
# get our speed if provided
|
# get our speed if provided
|
||||||
if "S" in command.Arguments:
|
if "S" in command.arguments:
|
||||||
self.LastValues["speed"] = command.getArgumentAsInt("S")
|
self.lastValues["speed"] = command.getArgumentAsInt("S")
|
||||||
|
|
||||||
# move to the next command
|
# move to the next command
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue