mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Better bounds checking in layer numbers
This commit is contained in:
parent
6bf3b1509a
commit
e1bb783bcd
1 changed files with 5 additions and 2 deletions
|
@ -92,8 +92,11 @@ class FilamentChange(Script):
|
||||||
layer_targets = layer_nums.split(",")
|
layer_targets = layer_nums.split(",")
|
||||||
if len(layer_targets) > 0:
|
if len(layer_targets) > 0:
|
||||||
for layer_num in layer_targets:
|
for layer_num in layer_targets:
|
||||||
layer_num = int(layer_num.strip()) + 1
|
try:
|
||||||
if layer_num <= len(data):
|
layer_num = int(layer_num.strip()) + 1 #Needs +1 because the 1st layer is reserved for start g-code.
|
||||||
|
except ValueError: #Layer number is not an integer.
|
||||||
|
continue
|
||||||
|
if 0 < layer_num < len(data):
|
||||||
data[layer_num] = color_change + data[layer_num]
|
data[layer_num] = color_change + data[layer_num]
|
||||||
|
|
||||||
return data
|
return data
|
Loading…
Add table
Add a link
Reference in a new issue