mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-24 23:23:57 -06:00
Fix material_diameter copy over for Extruders
CURA-4835
This commit is contained in:
parent
c7071c18dd
commit
7c85db4a18
2 changed files with 35 additions and 15 deletions
|
@ -18,10 +18,6 @@ if TYPE_CHECKING:
|
|||
from cura.Settings.GlobalStack import GlobalStack
|
||||
|
||||
|
||||
_EXTRUDER_SPECIFIC_DEFINITION_CHANGES_SETTINGS = ["machine_nozzle_size",
|
||||
"material_diameter"]
|
||||
|
||||
|
||||
## Represents an Extruder and its related containers.
|
||||
#
|
||||
#
|
||||
|
@ -53,20 +49,38 @@ class ExtruderStack(CuraContainerStack):
|
|||
# when we are upgrading a definition_changes container file, there is NO guarantee that other files such as
|
||||
# machine an extruder stack files are upgraded before this, so we cannot read those files assuming they are in
|
||||
# the latest format.
|
||||
#
|
||||
# MORE:
|
||||
# For single-extrusion machines, nozzle size is saved in the global stack, so the nozzle size value should be
|
||||
# carried to the first extruder.
|
||||
# For material diameter, it was supposed to be applied to all extruders, so its value should be copied to all
|
||||
# extruders.
|
||||
#
|
||||
keys_to_copy = ["material_diameter"] # material diameter will be copied to all extruders
|
||||
if self.getMetaDataEntry("position") == "0":
|
||||
for key in _EXTRUDER_SPECIFIC_DEFINITION_CHANGES_SETTINGS:
|
||||
setting_value = stack.definitionChanges.getProperty(key, "value")
|
||||
if setting_value is None:
|
||||
continue
|
||||
keys_to_copy.append("machine_nozzle_size")
|
||||
|
||||
setting_definition = stack.getSettingDefinition(key)
|
||||
new_instance = SettingInstance(setting_definition, self.definitionChanges)
|
||||
new_instance.setProperty("value", setting_value)
|
||||
new_instance.resetState() # Ensure that the state is not seen as a user state.
|
||||
self.definitionChanges.addInstance(new_instance)
|
||||
self.definitionChanges.setDirty(True)
|
||||
for key in keys_to_copy:
|
||||
# Only copy the value when this extruder doesn't have the value.
|
||||
if self.definitionChanges.hasProperty(key, "value"):
|
||||
continue
|
||||
setting_value = stack.definitionChanges.getProperty(key, "value")
|
||||
if setting_value is None:
|
||||
continue
|
||||
|
||||
stack.definitionChanges.removeInstance(key, postpone_emit = True)
|
||||
setting_definition = stack.getSettingDefinition(key)
|
||||
new_instance = SettingInstance(setting_definition, self.definitionChanges)
|
||||
new_instance.setProperty("value", setting_value)
|
||||
new_instance.resetState() # Ensure that the state is not seen as a user state.
|
||||
self.definitionChanges.addInstance(new_instance)
|
||||
self.definitionChanges.setDirty(True)
|
||||
|
||||
# NOTE: We cannot remove the setting from the global stack's definition changes container because for
|
||||
# material diameter, it needs to be applied to all extruders, but here we don't know how many extruders
|
||||
# a machine actually has and how many extruders has already been loaded for that machine, so we have to
|
||||
# keep this setting for any remaining extruders that haven't been loaded yet.
|
||||
#
|
||||
# Those settings will be removed in ExtruderManager which knows all those info.
|
||||
|
||||
@override(ContainerStack)
|
||||
def getNextStack(self) -> Optional["GlobalStack"]:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue