From 5ad0651fd190b7b887abb56052478e6b3dfbc0ce Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Thu, 23 Mar 2017 17:52:16 +0100 Subject: [PATCH] Add an "extruders" property and an addExtruder method Contributes to CURA-3497 --- cura/Settings/GlobalStack.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cura/Settings/GlobalStack.py b/cura/Settings/GlobalStack.py index 93a31d8e21..b605b8dc76 100644 --- a/cura/Settings/GlobalStack.py +++ b/cura/Settings/GlobalStack.py @@ -19,6 +19,8 @@ class GlobalStack(ContainerStack): self._empty_instance_container = ContainerRegistry.getInstance().getEmptyInstanceContainer() + self._extruders = [] + @pyqtProperty(InstanceContainer) def userChanges(self) -> InstanceContainer: return self._containers[_ContainerIndexes.UserChanges] @@ -59,6 +61,17 @@ class GlobalStack(ContainerStack): def definition(self) -> DefinitionContainer: return self._containers[_ContainerIndexes.Definition] + @pyqtProperty("QVariantList") + def extruders(self) -> list: + return self._extruders + + def addExtruder(self, extruder): + extruder_count = self.getProperty("machine_extruder_count", "value") + if len(self._extruders) > extruder_count: + raise Exceptions.TooManyExtrudersError("Tried to add extruder to {id} but its extruder count is {count}".format(id = self.id, count = extruder_count)) + + self._extruders.append(extruder) + ## Check whether the specified setting has a 'user' value. # # A user value here is defined as the setting having a value in either