mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Simplify indentation of pause at height script
Instead of making lots of nested if statements, use the if statements as an interruption check. This reduces the indentation a lot and makes it easier to read in my opinion. It also makes it easier to add stuff to these checks.
This commit is contained in:
parent
b44854d19d
commit
cfdde8dd07
1 changed files with 86 additions and 82 deletions
|
@ -102,7 +102,6 @@ class PauseAtHeight(Script):
|
|||
|
||||
x = 0.
|
||||
y = 0.
|
||||
current_z = 0.
|
||||
pause_height = self.getSettingValueByKey("pause_height")
|
||||
retraction_amount = self.getSettingValueByKey("retraction_amount")
|
||||
retraction_speed = self.getSettingValueByKey("retraction_speed")
|
||||
|
@ -132,7 +131,9 @@ class PauseAtHeight(Script):
|
|||
if not layers_started:
|
||||
continue
|
||||
|
||||
if self.getValue(line, 'G') == 1 or self.getValue(line, 'G') == 0:
|
||||
if self.getValue(line, 'G') != 1 and self.getValue(line, 'G') != 0:
|
||||
continue
|
||||
|
||||
current_z = self.getValue(line, 'Z')
|
||||
if not got_first_g_cmd_on_layer_0:
|
||||
layer_0_z = current_z
|
||||
|
@ -140,9 +141,13 @@ class PauseAtHeight(Script):
|
|||
|
||||
x = self.getValue(line, 'X', x)
|
||||
y = self.getValue(line, 'Y', y)
|
||||
if current_z is not None:
|
||||
if current_z is None:
|
||||
continue
|
||||
|
||||
current_height = current_z - layer_0_z
|
||||
if current_height >= pause_height:
|
||||
if current_height < pause_height:
|
||||
break #Try the next layer.
|
||||
|
||||
index = data.index(layer)
|
||||
prevLayer = data[index - 1]
|
||||
prevLines = prevLayer.split("\n")
|
||||
|
@ -217,5 +222,4 @@ class PauseAtHeight(Script):
|
|||
# modified data
|
||||
data[index] = layer
|
||||
return data
|
||||
break
|
||||
return data
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue