Add sanity check for GlobalStack CURA-5045

This commit is contained in:
Jack Ha 2018-05-07 10:30:45 +02:00
parent 5a194bb6d1
commit 00d8427e42
4 changed files with 24 additions and 5 deletions

View file

@ -153,6 +153,23 @@ class GlobalStack(CuraContainerStack):
return True
## Perform some sanity checks on the global stack
# Sanity check for extruders; they must have positions 0 and up to machine_extruder_count - 1
def isValid(self):
container_registry = ContainerRegistry.getInstance()
extruder_trains = container_registry.findContainerStacks(type = "extruder_train", machine = self.getId())
machine_extruder_count = self.getProperty("machine_extruder_count", "value")
extruder_check_position = set()
for extruder_train in extruder_trains:
extruder_position = extruder_train.getMetaDataEntry("position")
extruder_check_position.add(extruder_position)
for check_position in range(machine_extruder_count):
if str(check_position) not in extruder_check_position:
return False
return True
## private:
global_stack_mime = MimeType(