mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-29 23:34:32 +08:00
Merge pull request #5909 from Ultimaker/CURA-6590_fix_value_update_material
CURA-6590 Fix value update in material profile
This commit is contained in:
commit
c65fefce67
@ -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()))
|
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
|
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
|
# Prevent recursion
|
||||||
if not apply_to_all:
|
if not apply_to_all:
|
||||||
super().setMetaDataEntry(key, value)
|
super().setMetaDataEntry(key, value)
|
||||||
|
for k, v in new_setting_values_dict.items():
|
||||||
|
self.setProperty(k, "value", v)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Get the MaterialGroup
|
# Get the MaterialGroup
|
||||||
@ -74,17 +84,23 @@ class XmlMaterialProfile(InstanceContainer):
|
|||||||
material_group = material_manager.getMaterialGroup(root_material_id)
|
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.
|
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)
|
super().setMetaDataEntry(key, value)
|
||||||
|
for k, v in new_setting_values_dict.items():
|
||||||
|
self.setProperty(k, "value", v)
|
||||||
return
|
return
|
||||||
# Update the root material container
|
# Update the root material container
|
||||||
root_material_container = material_group.root_material_node.getContainer()
|
root_material_container = material_group.root_material_node.getContainer()
|
||||||
if root_material_container is not None:
|
if root_material_container is not None:
|
||||||
root_material_container.setMetaDataEntry(key, value, apply_to_all = False)
|
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
|
# Update all containers derived from it
|
||||||
for node in material_group.derived_material_node_list:
|
for node in material_group.derived_material_node_list:
|
||||||
container = node.getContainer()
|
container = node.getContainer()
|
||||||
if container is not None:
|
if container is not None:
|
||||||
container.setMetaDataEntry(key, value, apply_to_all = False)
|
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.
|
## Overridden from InstanceContainer, similar to setMetaDataEntry.
|
||||||
# without this function the setName would only set the name of the specific nozzle / material / machine combination container
|
# without this function the setName would only set the name of the specific nozzle / material / machine combination container
|
||||||
|
Loading…
x
Reference in New Issue
Block a user