mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-11 00:37:50 -06:00
Codestyle changes after merge
This commit is contained in:
parent
7d0b664c53
commit
717c11005b
1 changed files with 12 additions and 32 deletions
|
@ -117,34 +117,21 @@ class PauseAtHeight(Script):
|
||||||
}
|
}
|
||||||
}"""
|
}"""
|
||||||
|
|
||||||
|
|
||||||
def getNextXY(self, layer: str):
|
def getNextXY(self, layer: str):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Get the X and Y values for a layer (will be used to get X and Y of
|
Get the X and Y values for a layer (will be used to get X and Y of
|
||||||
the layer after the pause
|
the layer after the pause
|
||||||
"""
|
"""
|
||||||
|
|
||||||
lines = layer.split("\n")
|
lines = layer.split("\n")
|
||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
|
|
||||||
if self.getValue(line, "X") is not None and self.getValue(line, "Y") is not None:
|
if self.getValue(line, "X") is not None and self.getValue(line, "Y") is not None:
|
||||||
|
|
||||||
x = self.getValue(line, "X")
|
x = self.getValue(line, "X")
|
||||||
y = self.getValue(line, "Y")
|
y = self.getValue(line, "Y")
|
||||||
|
return x, y
|
||||||
return (x, y)
|
return 0, 0
|
||||||
|
|
||||||
return (0, 0)
|
|
||||||
|
|
||||||
|
|
||||||
def execute(self, data: list):
|
def execute(self, data: list):
|
||||||
|
|
||||||
"""data is a list. Each index contains a layer"""
|
"""data is a list. Each index contains a layer"""
|
||||||
|
|
||||||
x = 0.
|
|
||||||
y = 0.
|
|
||||||
pause_at = self.getSettingValueByKey("pause_at")
|
pause_at = self.getSettingValueByKey("pause_at")
|
||||||
pause_height = self.getSettingValueByKey("pause_height")
|
pause_height = self.getSettingValueByKey("pause_height")
|
||||||
pause_layer = self.getSettingValueByKey("pause_layer")
|
pause_layer = self.getSettingValueByKey("pause_layer")
|
||||||
|
@ -173,15 +160,12 @@ class PauseAtHeight(Script):
|
||||||
|
|
||||||
# Scroll each line of instruction for each layer in the G-code
|
# Scroll each line of instruction for each layer in the G-code
|
||||||
for line in lines:
|
for line in lines:
|
||||||
|
|
||||||
# Fist positive layer reached
|
# Fist positive layer reached
|
||||||
if ";LAYER:0" in line:
|
if ";LAYER:0" in line:
|
||||||
layers_started = True
|
layers_started = True
|
||||||
|
|
||||||
# Count nbr of negative layers (raft)
|
# Count nbr of negative layers (raft)
|
||||||
elif ";LAYER:-" in line:
|
elif ";LAYER:-" in line:
|
||||||
nbr_negative_layers += 1
|
nbr_negative_layers += 1
|
||||||
|
|
||||||
if not layers_started:
|
if not layers_started:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -190,7 +174,6 @@ class PauseAtHeight(Script):
|
||||||
current_z = self.getValue(line, "Z")
|
current_z = self.getValue(line, "Z")
|
||||||
|
|
||||||
if pause_at == "height":
|
if pause_at == "height":
|
||||||
|
|
||||||
# Ignore if the line is not G1 or G0
|
# Ignore if the line is not G1 or G0
|
||||||
if self.getValue(line, "G") != 1 and self.getValue(line, "G") != 0:
|
if self.getValue(line, "G") != 1 and self.getValue(line, "G") != 0:
|
||||||
continue
|
continue
|
||||||
|
@ -208,7 +191,6 @@ class PauseAtHeight(Script):
|
||||||
|
|
||||||
# Pause at layer
|
# Pause at layer
|
||||||
else:
|
else:
|
||||||
|
|
||||||
if not line.startswith(";LAYER:"):
|
if not line.startswith(";LAYER:"):
|
||||||
continue
|
continue
|
||||||
current_layer = line[len(";LAYER:"):]
|
current_layer = line[len(";LAYER:"):]
|
||||||
|
@ -224,36 +206,35 @@ class PauseAtHeight(Script):
|
||||||
|
|
||||||
# Get X and Y from the next layer (better position for
|
# Get X and Y from the next layer (better position for
|
||||||
# the nozzle)
|
# the nozzle)
|
||||||
nextLayer = data[index + 1]
|
next_layer = data[index + 1]
|
||||||
x, y = self.getNextXY(nextLayer)
|
x, y = self.getNextXY(next_layer)
|
||||||
|
|
||||||
prevLayer = data[index - 1]
|
prev_layer = data[index - 1]
|
||||||
prevLines = prevLayer.split("\n")
|
prev_lines = prev_layer.split("\n")
|
||||||
current_e = 0.
|
current_e = 0.
|
||||||
|
|
||||||
# Access last layer, browse it backwards to find
|
# Access last layer, browse it backwards to find
|
||||||
# last extruder absolute position
|
# last extruder absolute position
|
||||||
for prevLine in reversed(prevLines):
|
for prevLine in reversed(prev_lines):
|
||||||
current_e = self.getValue(prevLine, "E", -1)
|
current_e = self.getValue(prevLine, "E", -1)
|
||||||
if current_e >= 0:
|
if current_e >= 0:
|
||||||
break
|
break
|
||||||
|
|
||||||
# include a number of previous layers
|
# include a number of previous layers
|
||||||
for i in range(1, redo_layers + 1):
|
for i in range(1, redo_layers + 1):
|
||||||
prevLayer = data[index - i]
|
prev_layer = data[index - i]
|
||||||
layer = prevLayer + layer
|
layer = prev_layer + layer
|
||||||
|
|
||||||
# Get extruder's absolute position at the
|
# Get extruder's absolute position at the
|
||||||
# begining of the first layer redone
|
# beginning of the first layer redone
|
||||||
# see https://github.com/nallath/PostProcessingPlugin/issues/55
|
# see https://github.com/nallath/PostProcessingPlugin/issues/55
|
||||||
if i == redo_layers:
|
if i == redo_layers:
|
||||||
# Get X and Y from the next layer (better position for
|
# Get X and Y from the next layer (better position for
|
||||||
# the nozzle)
|
# the nozzle)
|
||||||
x, y = self.getNextXY(layer)
|
x, y = self.getNextXY(layer)
|
||||||
prevLines = prevLayer.split("\n")
|
prev_lines = prev_layer.split("\n")
|
||||||
for line in prevLines:
|
for line in prev_lines:
|
||||||
new_e = self.getValue(line, 'E', current_e)
|
new_e = self.getValue(line, 'E', current_e)
|
||||||
|
|
||||||
if new_e != current_e:
|
if new_e != current_e:
|
||||||
current_e = new_e
|
current_e = new_e
|
||||||
break
|
break
|
||||||
|
@ -319,7 +300,6 @@ class PauseAtHeight(Script):
|
||||||
|
|
||||||
layer = prepend_gcode + layer
|
layer = prepend_gcode + layer
|
||||||
|
|
||||||
|
|
||||||
# Override the data of this layer with the
|
# Override the data of this layer with the
|
||||||
# modified data
|
# modified data
|
||||||
data[index] = layer
|
data[index] = layer
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue