From 162e27691f2343d2ff56f6b4b36c289a0ef590a6 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 23 Sep 2015 15:16:00 +0200 Subject: [PATCH 1/4] Added file extension checking --- plugins/GCodeReader/GCodeReader.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/GCodeReader/GCodeReader.py b/plugins/GCodeReader/GCodeReader.py index 144d7c9d32..4bf8fb9a3f 100644 --- a/plugins/GCodeReader/GCodeReader.py +++ b/plugins/GCodeReader/GCodeReader.py @@ -3,6 +3,19 @@ from UM.Mesh.MeshReader import MeshReader +from cura.LayerData import LayerData +from cura.LayerDataDecorator import LayerDataDecorator + +import os + class GCodeReader(MeshReader): + def __init__(self): + super().__init__() + self._supported_extension = ".gcode" + def read(self, file_name): - pass \ No newline at end of file + extension = os.path.splitext(file_name)[1] + if extension.lower() == self._supported_extension: + with open (file_name,"rt") as f: + for line in f: + pass \ No newline at end of file From cd3c3729e9f7d262d141789db480cd86e462cb78 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 30 Sep 2015 09:20:14 +0200 Subject: [PATCH 2/4] G-code loader now works somewhat, still WIP --- plugins/GCodeReader/GCodeReader.py | 91 +++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/plugins/GCodeReader/GCodeReader.py b/plugins/GCodeReader/GCodeReader.py index 4bf8fb9a3f..01acaecf31 100644 --- a/plugins/GCodeReader/GCodeReader.py +++ b/plugins/GCodeReader/GCodeReader.py @@ -2,20 +2,109 @@ # Cura is released under the terms of the AGPLv3 or higher. from UM.Mesh.MeshReader import MeshReader +from UM.Application import Application +from UM.Scene.SceneNode import SceneNode +from UM.Mesh.MeshData import MeshData from cura.LayerData import LayerData from cura.LayerDataDecorator import LayerDataDecorator import os +import numpy class GCodeReader(MeshReader): def __init__(self): super().__init__() self._supported_extension = ".gcode" + self._scene = Application.getInstance().getController().getScene() def read(self, file_name): extension = os.path.splitext(file_name)[1] if extension.lower() == self._supported_extension: + layer_data = LayerData() with open (file_name,"rt") as f: + layer = "" + current_path_type = "" + + current_layer_nr = 0 + poly_list = [] + old_position = [0,0,0] + current_z = 0 for line in f: - pass \ No newline at end of file + if line.startswith(';TYPE:'): + current_path_type = line[6:].strip() + #layer_data.addPolygon(current_layer_nr,3 ,None ,5 ) + elif line.startswith(';LAYER:'): + current_layer_nr = int(line[7:].strip()) + layer_data.addLayer(int(line[7:].strip())) + elif line.startswith(';'): + pass # Ignore comments + else: + command_type = self.getCodeInt(line, 'G') + if command_type == 0 or command_type == 1: #Move command + x = self.getCodeFloat(line, 'X') + y = self.getCodeFloat(line, 'Y') + z = self.getCodeFloat(line, 'Z') + if z: + current_z = z + if x and y: + polygon_data = numpy.zeros((4,3)) #Square :) + polygon_data[0,:] = old_position + polygon_data[1,:] = old_position + polygon_data[2,:] = [x,current_z,y] + polygon_data[3,:] = [x,current_z,y] + old_position = [x,current_z,y] + if current_path_type == "SKIRT": + layer_data.addPolygon(current_layer_nr,5 ,polygon_data ,5 ) + elif current_path_type == "WALL-INNER": + layer_data.addPolygon(current_layer_nr,3 ,polygon_data ,5 ) + elif current_path_type == "WALL-OUTER": + layer_data.addPolygon(current_layer_nr,1 ,polygon_data ,5 ) + else: + layer_data.addPolygon(current_layer_nr,2 ,polygon_data ,5 ) + #e = self.getCodeFloat(line, 'E') + #print(x , " ", y , " ", z, " " , e) + pass + layer_data.build() + decorator = LayerDataDecorator() + decorator.setLayerData(layer_data) + new_node = SceneNode() + new_node.setMeshData(MeshData()) + new_node.addDecorator(decorator) + new_node.setParent(self._scene.getRoot()) + + + ## Gets the value after the 'code' as int + # example: line = "G50" and code is "G" this function will return 50 + # \param line string containing g-code. + # \param code string Letter to look for. + # \sa getCodeFloat + # \returns int + def getCodeInt(self, line, code): + n = line.find(code) + 1 + if n < 1: + return None + m = line.find(' ', n) + try: + if m < 0: + return int(line[n:]) + return int(line[n:m]) + except: + return None + ## Gets the value after the 'code' as float + # example: line = "G50" and code is "G" this function will return 50 + # \param line string containing g-code. + # \param code string Letter to look for. + # \sa getCodeInt + # \returns float + def getCodeFloat(self, line, code): + n = line.find(code) + 1 + if n < 1: + return None + m = line.find(' ', n) + try: + if m < 0: + return float(line[n:]) + return float(line[n:m]) + except: + return None \ No newline at end of file From 38d2bff8c6cd066fd4e1d279bc981106a5941dd2 Mon Sep 17 00:00:00 2001 From: Kurt Loeffler Date: Tue, 22 Dec 2015 22:49:13 -0800 Subject: [PATCH 3/4] Moved Nozzle Diameter into a new "Machine" category in the UI. This category needs icon art. --- resources/machines/fdmprinter.json | 15 +++++++++++---- resources/machines/ultimaker2.json | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/resources/machines/fdmprinter.json b/resources/machines/fdmprinter.json index 8952ebebb9..b2b6e92280 100644 --- a/resources/machines/fdmprinter.json +++ b/resources/machines/fdmprinter.json @@ -146,20 +146,27 @@ } }, "categories": { - "resolution": { - "label": "Quality", + "machine": { + "label": "Machine", "visible": true, "icon": "category_layer_height", "settings": { "machine_nozzle_size": { "label": "Nozzle Diameter", - "description": "The inner diameter of the hole in the nozzle.", + "description": "The inner diameter of the nozzle.", "unit": "mm", "type": "float", "default": 0.4, "min_value": "0.001", "visible": false - }, + } + } + }, + "resolution": { + "label": "Quality", + "visible": true, + "icon": "category_layer_height", + "settings": { "layer_height": { "label": "Layer Height", "description": "The height of each layer, in mm. Normal quality prints are 0.1mm, high quality is 0.06mm. You can go up to 0.25mm with an Ultimaker for very fast prints at low quality. For most purposes, layer heights between 0.1 and 0.2mm give a good tradeoff of speed and surface finish.", diff --git a/resources/machines/ultimaker2.json b/resources/machines/ultimaker2.json index f4bbf5011a..582212fd08 100644 --- a/resources/machines/ultimaker2.json +++ b/resources/machines/ultimaker2.json @@ -63,7 +63,7 @@ ] }, "machine_center_is_zero": { "default": false }, - "machine_nozzle_size": { "default": 0.4, "description": "The inner diameter of the hole in the nozzle. If you are using an Olsson Block with a non-standard nozzle then set this field to the nozzle size you are using." }, + "machine_nozzle_size": { "default": 0.4, "min_value": "0.001", "description": "The inner diameter of the nozzle. If you are using an Olsson Block with a non-standard nozzle diameter, set this field to the diameter you are using." }, "machine_nozzle_heat_up_speed": { "default": 2.0 }, "machine_nozzle_cool_down_speed": { "default": 2.0 }, "gantry_height": { "default": 55 }, From d6b6c919fc58bd44fb79e8e2ff5f7e43e4591bfc Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 15 Jan 2016 17:13:36 +0100 Subject: [PATCH 4/4] Fix typo in preference description nog -> not --- resources/qml/ViewPage.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/ViewPage.qml b/resources/qml/ViewPage.qml index 7b33345a9a..6204b47ee6 100644 --- a/resources/qml/ViewPage.qml +++ b/resources/qml/ViewPage.qml @@ -30,7 +30,7 @@ UM.PreferencesPage width: childrenRect.width; height: childrenRect.height; - text: catalog.i18nc("@info:tooltip","Highlight unsupported areas of the model in red. Without support these areas will nog print properly.") + text: catalog.i18nc("@info:tooltip","Highlight unsupported areas of the model in red. Without support these areas will not print properly.") CheckBox {