mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Keep per object extruder when switching machines. CURA-2533
This commit is contained in:
parent
80a5978d54
commit
3f6877d2ec
2 changed files with 20 additions and 2 deletions
|
@ -61,6 +61,15 @@ class SettingOverrideDecorator(SceneNodeDecorator):
|
||||||
def getActiveExtruder(self):
|
def getActiveExtruder(self):
|
||||||
return self._extruder_stack
|
return self._extruder_stack
|
||||||
|
|
||||||
|
## Gets the currently active extruders position
|
||||||
|
#
|
||||||
|
# \return An extruder's position, or None if no position info is available.
|
||||||
|
def getActiveExtruderPosition(self):
|
||||||
|
containers = ContainerRegistry.getInstance().findContainers(id = self.getActiveExtruder())
|
||||||
|
if containers:
|
||||||
|
container_stack = containers[0]
|
||||||
|
return container_stack.getMetaDataEntry("position", default=None)
|
||||||
|
|
||||||
def _onSettingChanged(self, instance, property_name): # Reminder: 'property' is a built-in function
|
def _onSettingChanged(self, instance, property_name): # Reminder: 'property' is a built-in function
|
||||||
if property_name == "value": # Only reslice if the value has changed.
|
if property_name == "value": # Only reslice if the value has changed.
|
||||||
Application.getInstance().getBackend().forceSlice()
|
Application.getInstance().getBackend().forceSlice()
|
||||||
|
|
|
@ -84,11 +84,20 @@ class PerObjectSettingsTool(Tool):
|
||||||
default_stack = ExtruderManager.getInstance().getExtruderStack(0)
|
default_stack = ExtruderManager.getInstance().getExtruderStack(0)
|
||||||
if default_stack:
|
if default_stack:
|
||||||
default_stack_id = default_stack.getId()
|
default_stack_id = default_stack.getId()
|
||||||
else: default_stack_id = global_container_stack.getId()
|
else:
|
||||||
|
default_stack_id = global_container_stack.getId()
|
||||||
|
|
||||||
root_node = Application.getInstance().getController().getScene().getRoot()
|
root_node = Application.getInstance().getController().getScene().getRoot()
|
||||||
for node in DepthFirstIterator(root_node):
|
for node in DepthFirstIterator(root_node):
|
||||||
node.callDecoration("setActiveExtruder", default_stack_id)
|
new_stack_id = default_stack_id
|
||||||
|
# Get position of old extruder stack for this node
|
||||||
|
old_extruder_pos = node.callDecoration("getActiveExtruderPosition")
|
||||||
|
if old_extruder_pos is not None:
|
||||||
|
# Fetch current (new) extruder stack at position
|
||||||
|
new_stack = ExtruderManager.getInstance().getExtruderStack(old_extruder_pos)
|
||||||
|
if new_stack:
|
||||||
|
new_stack_id = new_stack.getId()
|
||||||
|
node.callDecoration("setActiveExtruder", new_stack_id)
|
||||||
|
|
||||||
self._updateEnabled()
|
self._updateEnabled()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue