diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 2ab7837352..ee5fdfea2a 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -581,7 +581,7 @@ class CuraApplication(QtApplication): count = 0 scene_bounding_box = None for node in DepthFirstIterator(self.getController().getScene().getRoot()): - if type(node) is not SceneNode or not node.getMeshData(): + if type(node) is not SceneNode or (not node.getMeshData() and not hasattr(node, "gcode")): continue count += 1 @@ -712,7 +712,7 @@ class CuraApplication(QtApplication): for node in DepthFirstIterator(self.getController().getScene().getRoot()): if type(node) is not SceneNode: continue - if not node.getMeshData() and not node.callDecoration("isGroup"): + if (not node.getMeshData() and not hasattr(node, "gcode")) and not node.callDecoration("isGroup"): continue # Node that doesnt have a mesh and is not a group. if node.getParent() and node.getParent().callDecoration("isGroup"): continue # Grouped nodes don't need resetting as their parent (the group) is resetted) diff --git a/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py b/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py index c4e9554b2c..206a3e83e8 100644 --- a/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py +++ b/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py @@ -60,7 +60,7 @@ class ProcessSlicedLayersJob(Job): for node in DepthFirstIterator(self._scene.getRoot()): if node.callDecoration("getLayerData"): node.getParent().removeChild(node) - break + # break if self._abort_requested: if self._progress: self._progress.hide() diff --git a/plugins/GCODEReader/GCODEReader.py b/plugins/GCODEReader/GCODEReader.py index b63268ce7f..abaefdadbd 100644 --- a/plugins/GCODEReader/GCODEReader.py +++ b/plugins/GCODEReader/GCODEReader.py @@ -4,11 +4,15 @@ from UM.Mesh.MeshReader import MeshReader from UM.Mesh.MeshBuilder import MeshBuilder +from UM.Mesh.MeshData import MeshData import os from UM.Scene.SceneNode import SceneNode +from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator from UM.Math.Vector import Vector +from UM.Math.Color import Color from UM.Math.AxisAlignedBox import AxisAlignedBox from UM.Application import Application +from UM.Preferences import Preferences from cura import LayerDataBuilder from cura import LayerDataDecorator @@ -59,6 +63,14 @@ class GCODEReader(MeshReader): extension = os.path.splitext(file_name)[1] if extension.lower() in self._supported_extensions: + scene = Application.getInstance().getController().getScene() + if getattr(scene, "gcode_list"): + setattr(scene, "gcode_list", None) + for node in DepthFirstIterator(scene.getRoot()): + if node.callDecoration("getLayerData"): + node.getParent().removeChild(node) + Application.getInstance().deleteAll() + scene_node = SceneNode() # mesh_builder = MeshBuilder() @@ -73,11 +85,14 @@ class GCODEReader(MeshReader): # # scene_node.setMeshData(mesh_builder.build()) - # scene_node.getBoundingBox = getBoundingBox + def getBoundingBox(): + return AxisAlignedBox(minimum=Vector(0, 0, 0), maximum=Vector(10, 10, 10)) + + scene_node.getBoundingBox = getBoundingBox scene_node.gcode = True - backend = Application.getInstance().getBackend() - backend._pauseSlicing = True - backend.backendStateChange.emit(0) + # backend = Application.getInstance().getBackend() + # backend._pauseSlicing = True + # backend.backendStateChange.emit(0) file = open(file_name, "r") @@ -183,12 +198,17 @@ class GCODEReader(MeshReader): scene_node_parent = Application.getInstance().getBuildVolume() scene_node.setParent(scene_node_parent) - mesh_builder = MeshBuilder() - mesh_builder.setFileName(file_name) + # mesh_builder = MeshBuilder() + # mesh_builder.setFileName(file_name) + # + # mesh_builder.addCube(10, 10, 10, Vector(0, -5, 0)) - mesh_builder.addCube(10, 10, 10, Vector(0, -5, 0)) + # scene_node.setMeshData(mesh_builder.build()) + # scene_node.setMeshData(MeshData(file_name=file_name)) - scene_node.setMeshData(mesh_builder.build()) + # Application.getInstance().getPrintInformation().JobName(file_name) + + Preferences.getInstance().setValue("cura/jobname_prefix", False) settings = Application.getInstance().getGlobalContainerStack() machine_width = settings.getProperty("machine_width", "value") @@ -200,7 +220,7 @@ class GCODEReader(MeshReader): if view.getPluginId() == "LayerView": view.resetLayerData() - scene_node.setEnabled(False) + # scene_node.setEnabled(False) #scene_node.setSelectable(False) return scene_node diff --git a/plugins/LayerView/LayerPass.py b/plugins/LayerView/LayerPass.py index 287f3c3539..9e610b68d2 100644 --- a/plugins/LayerView/LayerPass.py +++ b/plugins/LayerView/LayerPass.py @@ -49,7 +49,7 @@ class LayerPass(RenderPass): if isinstance(node, ToolHandle): tool_handle_batch.addItem(node.getWorldTransformation(), mesh = node.getSolidMesh()) - elif isinstance(node, SceneNode) and (node.getMeshData()) and node.isVisible(): + elif isinstance(node, SceneNode) and (node.getMeshData() or hasattr(node, "gcode")) and node.isVisible(): layer_data = node.callDecoration("getLayerData") if not layer_data: continue diff --git a/plugins/LayerView/LayerView.py b/plugins/LayerView/LayerView.py index 50c13194f7..0bae9c891c 100644 --- a/plugins/LayerView/LayerView.py +++ b/plugins/LayerView/LayerView.py @@ -119,7 +119,7 @@ class LayerView(View): continue if not node.render(renderer): - if node.getMeshData() and node.isVisible(): + if (node.getMeshData()) and node.isVisible(): renderer.queueNode(node, transparent = True, shader = self._ghost_shader) def setLayer(self, value):