diff --git a/cura/Settings/ContainerManager.py b/cura/Settings/ContainerManager.py index 1fcdbc5a20..9a2282c8c0 100644 --- a/cura/Settings/ContainerManager.py +++ b/cura/Settings/ContainerManager.py @@ -235,7 +235,7 @@ class ContainerManager(QObject): return True - ## Set a setting property value of the specified container. + ## Set a setting property of the specified container. # # This will set the specified property of the specified setting of the container # and all containers that share the same base_file (if any). The latter only @@ -269,6 +269,29 @@ class ContainerManager(QObject): return True + ## Get a setting property of the specified container. + # + # This will get the specified property of the specified setting of the + # specified container. + # + # \param container_id The ID of the container to get the setting property + # of. + # \param setting_key The key of the setting to get the property of. + # \param property_name The property to obtain. + # \return The value of the specified property. The type of this property + # value depends on the type of the property. For instance, the "value" + # property of an integer setting will be a Python int, but the "value" + # property of an enum setting will be a Python str. + @pyqtSlot(str, str, str, result = QVariant) + def getContainerProperty(self, container_id: str, setting_key: str, property_name: str): + containers = self._container_registry.findContainers(id = container_id) + if not containers: + Logger.log("w", "Could not get properties of container %s because it was not found.", container_id) + return "" + container = containers[0] + + return container.getProperty(setting_key, property_name) + ## Set the name of the specified container. @pyqtSlot(str, str, result = bool) def setContainerName(self, container_id, new_name):