mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 09:47:50 -06:00
Add a SetObjectExtruderOperation class
It handles setting an extruder for an object. Contributes to CURA-3609
This commit is contained in:
parent
03ccdec861
commit
61f542c215
1 changed files with 27 additions and 0 deletions
27
cura/Settings/SetObjectExtruderOperation.py
Normal file
27
cura/Settings/SetObjectExtruderOperation.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Copyright (c) 2017 Ultimaker B.V.
|
||||
# Cura is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
from UM.Scene.SceneNode import SceneNode
|
||||
from UM.Operations.Operation import Operation
|
||||
|
||||
from cura.Settings.SettingOverrideDecorator import SettingOverrideDecorator
|
||||
|
||||
## Simple operation to set the extruder a certain object should be printed with.
|
||||
class SetObjectExtruderOperation(Operation):
|
||||
def __init__(self, node: SceneNode, extruder_id: str) -> None:
|
||||
self._node = node
|
||||
self._extruder_id = extruder_id
|
||||
self._previous_extruder_id = None
|
||||
self._decorator_added = False
|
||||
|
||||
def undo(self):
|
||||
if self._previous_extruder_id:
|
||||
self._node.callDecoration("setActiveExtruder", self._previous_extruder_id)
|
||||
|
||||
def redo(self):
|
||||
stack = self._node.callDecoration("getStack") #Don't try to get the active extruder since it may be None anyway.
|
||||
if not stack:
|
||||
self._node.addDecorator(SettingOverrideDecorator())
|
||||
|
||||
self._previous_extruder_id = self._node.callDecoration("getActiveExtruder")
|
||||
self._node.callDecoration("setActiveExtruder", self._extruder_id)
|
Loading…
Add table
Add a link
Reference in a new issue