mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-10 16:27:51 -06:00
Set properties for all containers with the same base_file metadata entry
This commit is contained in:
parent
a7cdf49018
commit
c9998ca6fe
1 changed files with 12 additions and 2 deletions
|
@ -237,6 +237,10 @@ class ContainerManager(QObject):
|
||||||
|
|
||||||
## Set a metadata entry of the specified container.
|
## Set a metadata entry 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
|
||||||
|
# happens for material containers.
|
||||||
|
#
|
||||||
# \param container_id \type{str} The ID of the container to change.
|
# \param container_id \type{str} The ID of the container to change.
|
||||||
# \param setting_key \type{str} The key of the setting.
|
# \param setting_key \type{str} The key of the setting.
|
||||||
# \param property_name \type{str} The name of the property, eg "value".
|
# \param property_name \type{str} The name of the property, eg "value".
|
||||||
|
@ -244,7 +248,7 @@ class ContainerManager(QObject):
|
||||||
#
|
#
|
||||||
# \return True if successful, False if not.
|
# \return True if successful, False if not.
|
||||||
@pyqtSlot(str, str, str, str, result = bool)
|
@pyqtSlot(str, str, str, str, result = bool)
|
||||||
def setContainerProperty(self, container_id, setting_key, property_name, value_value):
|
def setContainerProperty(self, container_id, setting_key, property_name, property_value):
|
||||||
containers = self._container_registry.findContainers(None, id = container_id)
|
containers = self._container_registry.findContainers(None, id = container_id)
|
||||||
if not containers:
|
if not containers:
|
||||||
Logger.log("w", "Could not set properties of container %s because it was not found.", container_id)
|
Logger.log("w", "Could not set properties of container %s because it was not found.", container_id)
|
||||||
|
@ -256,7 +260,13 @@ class ContainerManager(QObject):
|
||||||
Logger.log("w", "Cannot set properties of read-only container %s.", container_id)
|
Logger.log("w", "Cannot set properties of read-only container %s.", container_id)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
container.setProperty(setting_key, property_name, value_value)
|
container.setProperty(setting_key, property_name, property_value)
|
||||||
|
|
||||||
|
basefile = container.getMetaDataEntry("base_file", container_id)
|
||||||
|
for sibbling_container in ContainerRegistry.getInstance().findInstanceContainers(base_file = basefile):
|
||||||
|
print(sibbling_container.getId())
|
||||||
|
if sibbling_container != container:
|
||||||
|
sibbling_container.setProperty(setting_key, property_name, property_value)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue