From 87dc3535bbbd2ad3d66b9579fcda6b375920eaec Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 15 Jan 2018 09:59:02 +0100 Subject: [PATCH 1/4] Use isinstance() for SceneNode type check CURA-4525 --- cura/CuraApplication.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 02c5c04203..ab7c093b1d 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -1041,7 +1041,7 @@ class CuraApplication(QtApplication): nodes = [] for node in DepthFirstIterator(self.getController().getScene().getRoot()): - if type(node) not in {SceneNode, CuraSceneNode}: + if not isinstance(node, SceneNode): continue if (not node.getMeshData() and not node.callDecoration("getLayerData")) and not node.callDecoration("isGroup"): continue # Node that doesnt have a mesh and is not a group. From 20e7fe911fdebb9fb74df4ae5490e1e423252504 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 15 Jan 2018 10:49:38 +0100 Subject: [PATCH 2/4] Only save models on the active build plate in 3MFWriter CURA-4792 --- plugins/3MFWriter/ThreeMFWriter.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/plugins/3MFWriter/ThreeMFWriter.py b/plugins/3MFWriter/ThreeMFWriter.py index 79b821fe31..c4b7035cf1 100644 --- a/plugins/3MFWriter/ThreeMFWriter.py +++ b/plugins/3MFWriter/ThreeMFWriter.py @@ -6,8 +6,9 @@ from UM.Math.Vector import Vector from UM.Logger import Logger from UM.Math.Matrix import Matrix from UM.Application import Application -import UM.Scene.SceneNode -from cura.Scene.CuraSceneNode import CuraSceneNode +from UM.Scene.SceneNode import SceneNode + +from cura.CuraApplication import CuraApplication import Savitar @@ -62,11 +63,15 @@ class ThreeMFWriter(MeshWriter): self._store_archive = store_archive ## Convenience function that converts an Uranium SceneNode object to a SavitarSceneNode - # \returns Uranium Scenen node. + # \returns Uranium Scene node. def _convertUMNodeToSavitarNode(self, um_node, transformation = Matrix()): - if type(um_node) not in [UM.Scene.SceneNode.SceneNode, CuraSceneNode]: + if not isinstance(um_node, SceneNode): return None + active_build_plate_nr = CuraApplication.getInstance().getBuildPlateModel().activeBuildPlate + if um_node.callDecoration("getBuildPlateNumber") != active_build_plate_nr: + return + savitar_node = Savitar.SceneNode() node_matrix = um_node.getLocalTransformation() @@ -97,6 +102,9 @@ class ThreeMFWriter(MeshWriter): savitar_node.setSetting(key, str(stack.getProperty(key, "value"))) for child_node in um_node.getChildren(): + # only save the nodes on the active build plate + if child_node.callDecoration("getBuildPlateNumber") != active_build_plate_nr: + continue savitar_child_node = self._convertUMNodeToSavitarNode(child_node) if savitar_child_node is not None: savitar_node.addChild(savitar_child_node) From b60903afc2d4770b367ba79074b40bbc0c304249 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 15 Jan 2018 11:02:52 +0100 Subject: [PATCH 3/4] Fix setting new ID in project loading CURA-4795 --- plugins/3MFReader/ThreeMFWorkspaceReader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/3MFReader/ThreeMFWorkspaceReader.py b/plugins/3MFReader/ThreeMFWorkspaceReader.py index 40d64590f5..5c62c361c3 100755 --- a/plugins/3MFReader/ThreeMFWorkspaceReader.py +++ b/plugins/3MFReader/ThreeMFWorkspaceReader.py @@ -609,7 +609,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader): instance_container.setName(self._container_registry.uniqueName(instance_container.getName())) new_changes_container_id = self.getNewId(instance_container.getId()) - instance_container._id = new_changes_container_id + instance_container.setMetaDataEntry("id", new_changes_container_id) # TODO: we don't know the following is correct or not, need to verify # AND REFACTOR!!! From dc596d0e1e041dfa024702463bcf04b3a55278c3 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 15 Jan 2018 11:12:07 +0100 Subject: [PATCH 4/4] Only remove selectable nodes in deleteAll() CURA-4795 Otherwise, after loading a project file, all nodes including the machine will be removed and you don't see the machine any more. --- cura/CuraApplication.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index ab7c093b1d..756dae2704 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -1045,6 +1045,8 @@ class CuraApplication(QtApplication): continue if (not node.getMeshData() and not node.callDecoration("getLayerData")) and not node.callDecoration("isGroup"): continue # Node that doesnt have a mesh and is not a group. + if not node.isSelectable(): + continue # Only remove nodes that are selectable. if node.getParent() and node.getParent().callDecoration("isGroup"): continue # Grouped nodes don't need resetting as their parent (the group) is resetted) nodes.append(node)