diff options
author | Lipu Fei <lipu.fei815@gmail.com> | 2019-06-18 12:23:04 +0300 |
---|---|---|
committer | Lipu Fei <lipu.fei815@gmail.com> | 2019-06-18 12:23:28 +0300 |
commit | 51dc7b1b8e1d9a95f6774174bd7ab0d5d7802c71 (patch) | |
tree | ee050f2bc45f45cbc71eb6a7b2178e8fdce9e238 /plugins/XmlMaterialProfile/XmlMaterialProfile.py | |
parent | 9236f21d67756eaa0a9829850bbdf9777284d694 (diff) |
Fix value update in material profile
CURA-6590
Diffstat (limited to 'plugins/XmlMaterialProfile/XmlMaterialProfile.py')
-rw-r--r-- | plugins/XmlMaterialProfile/XmlMaterialProfile.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/plugins/XmlMaterialProfile/XmlMaterialProfile.py b/plugins/XmlMaterialProfile/XmlMaterialProfile.py index f057585cb5..0760581c70 100644 --- a/plugins/XmlMaterialProfile/XmlMaterialProfile.py +++ b/plugins/XmlMaterialProfile/XmlMaterialProfile.py @@ -63,9 +63,19 @@ class XmlMaterialProfile(InstanceContainer): Logger.log("w", "Can't change metadata {key} of material {material_id} because it's read-only.".format(key = key, material_id = self.getId())) return + # Some metadata such as diameter should also be instantiated to be a setting. Go though all values for the + # "properties" field and apply the new values to SettingInstances as well. + new_setting_values_dict = {} + if key == "properties": + for k, v in value.items(): + if k in self.__material_properties_setting_map: + new_setting_values_dict[self.__material_properties_setting_map[k]] = v + # Prevent recursion if not apply_to_all: super().setMetaDataEntry(key, value) + for k, v in new_setting_values_dict.items(): + self.setProperty(k, "value", v) return # Get the MaterialGroup @@ -74,17 +84,23 @@ class XmlMaterialProfile(InstanceContainer): material_group = material_manager.getMaterialGroup(root_material_id) if not material_group: #If the profile is not registered in the registry but loose/temporary, it will not have a base file tree. super().setMetaDataEntry(key, value) + for k, v in new_setting_values_dict.items(): + self.setProperty(k, "value", v) return # Update the root material container root_material_container = material_group.root_material_node.getContainer() if root_material_container is not None: root_material_container.setMetaDataEntry(key, value, apply_to_all = False) + for k, v in new_setting_values_dict.items(): + root_material_container.setProperty(k, "value", v) # Update all containers derived from it for node in material_group.derived_material_node_list: container = node.getContainer() if container is not None: container.setMetaDataEntry(key, value, apply_to_all = False) + for k, v in new_setting_values_dict.items(): + container.setProperty(k, "value", v) ## Overridden from InstanceContainer, similar to setMetaDataEntry. # without this function the setName would only set the name of the specific nozzle / material / machine combination container |