Пример #1
0
    def setExtruderForSelection(self, extruder_id: str) -> None:
        operation = GroupedOperation()

        nodes_to_change = []
        for node in Selection.getAllSelectedObjects():
            # If the node is a group, apply the active extruder to all children of the group.
            if node.callDecoration("isGroup"):
                for grouped_node in BreadthFirstIterator(node): #type: ignore #Ignore type error because iter() should get called automatically by Python syntax.
                    if grouped_node.callDecoration("getActiveExtruder") == extruder_id:
                        continue

                    if grouped_node.callDecoration("isGroup"):
                        continue

                    nodes_to_change.append(grouped_node)
                continue

            # Do not change any nodes that already have the right extruder set.
            if node.callDecoration("getActiveExtruder") == extruder_id:
                continue

            nodes_to_change.append(node)

        if not nodes_to_change:
            # If there are no changes to make, we still need to reset the selected extruders.
            # This is a workaround for checked menu items being deselected while still being
            # selected.
            ExtruderManager.getInstance().resetSelectedObjectExtruders()
            return

        for node in nodes_to_change:
            operation.addOperation(SetObjectExtruderOperation(node, extruder_id))
        operation.push()
Пример #2
0
    def __init__(self, node, parent=None):
        super().__init__(parent)
        self.node = node
        self.setTransformation(node.getLocalTransformation())
        self.setMeshData(node.getMeshData())
        self.setVisible(deepcopy(node.isVisible()))
        self._selectable = False
        self._name = deepcopy(node.getName())
        # Make sure the BuildPlateDecorator is added the first
        build_plate_decorator = node.getDecorator(BuildPlateDecorator)
        if build_plate_decorator is not None:
            self.addDecorator(deepcopy(build_plate_decorator))
        for decorator in node.getDecorators():
            self.addDecorator(deepcopy(decorator))

        for child in node.getChildren():
            if isinstance(child, CuraSceneNode):
                self.addChild(DuplicatedNode(child))
            else:
                self.addChild(deepcopy(child))

        node.calculateBoundingBoxMesh()
        self.node.transformationChanged.connect(self._onTransformationChanged)
        self.node.parentChanged.connect(self._someParentChanged)
        self.parentChanged.connect(self._someParentChanged)
        SetObjectExtruderOperation(
            self,
            ExtruderManager.getInstance().getExtruderStack(1).getId()).redo()