From 6a1942c254cc241da90712744522571ee71f1c05 Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Thu, 23 Jun 2016 19:40:00 +0200 Subject: [PATCH 1/7] GCodeWriter: Exporting the data as done on regualar exports --- plugins/GCodeWriter/GCodeWriter.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/plugins/GCodeWriter/GCodeWriter.py b/plugins/GCodeWriter/GCodeWriter.py index d304f0d046..c80d8e610a 100644 --- a/plugins/GCodeWriter/GCodeWriter.py +++ b/plugins/GCodeWriter/GCodeWriter.py @@ -23,7 +23,7 @@ class GCodeWriter(MeshWriter): # It can only read settings with the same version as the version it was # written with. If the file format is changed in a way that breaks reverse # compatibility, increment this version number! - version = 1 + version = 2 ## Dictionary that defines how characters are escaped when embedded in # g-code. @@ -68,23 +68,21 @@ class GCodeWriter(MeshWriter): prefix = ";SETTING_" + str(GCodeWriter.version) + " " # The prefix to put before each line. prefix_length = len(prefix) - all_settings = InstanceContainer("G-code-imported-profile") #Create a new 'profile' with ALL settings so that the slice can be precisely reproduced. - all_settings.setDefinition(settings.getBottom()) - for key in settings.getAllKeys(): - all_settings.setProperty(key, "value", settings.getProperty(key, "value")) #Just copy everything over to the setting instance. - serialised = all_settings.serialize() + global_stack = Application.getInstance().getGlobalContainerStack() + container_with_settings = global_stack.getContainers()[1] + serialized = container_with_settings.serialize() # Escape characters that have a special meaning in g-code comments. pattern = re.compile("|".join(GCodeWriter.escape_characters.keys())) # Perform the replacement with a regular expression. - serialised = pattern.sub(lambda m: GCodeWriter.escape_characters[re.escape(m.group(0))], serialised) + serialized = pattern.sub(lambda m: GCodeWriter.escape_characters[re.escape(m.group(0))], serialized) # Introduce line breaks so that each comment is no longer than 80 characters. Prepend each line with the prefix. result = "" # Lines have 80 characters, so the payload of each line is 80 - prefix. - for pos in range(0, len(serialised), 80 - prefix_length): - result += prefix + serialised[pos : pos + 80 - prefix_length] + "\n" - serialised = result + for pos in range(0, len(serialized), 80 - prefix_length): + result += prefix + serialized[pos : pos + 80 - prefix_length] + "\n" + serialized = result - return serialised \ No newline at end of file + return serialized \ No newline at end of file From 1fdf835c19bf8687c7ff1998d306a1301b13c768 Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Thu, 23 Jun 2016 19:40:52 +0200 Subject: [PATCH 2/7] GCodeProfileReader: Increasing the setting version --- plugins/GCodeProfileReader/GCodeProfileReader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/GCodeProfileReader/GCodeProfileReader.py b/plugins/GCodeProfileReader/GCodeProfileReader.py index 5dcea88aed..5915395005 100644 --- a/plugins/GCodeProfileReader/GCodeProfileReader.py +++ b/plugins/GCodeProfileReader/GCodeProfileReader.py @@ -22,7 +22,7 @@ class GCodeProfileReader(ProfileReader): # It can only read settings with the same version as the version it was # written with. If the file format is changed in a way that breaks reverse # compatibility, increment this version number! - version = 1 + version = 2 ## Dictionary that defines how characters are escaped when embedded in # g-code. From d49ba8011775957eebc63f17aed808216629da1b Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Fri, 24 Jun 2016 16:00:38 +0200 Subject: [PATCH 3/7] GCodeWriter: Getting always the correct container with the currently used profile. --- plugins/GCodeWriter/GCodeWriter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/GCodeWriter/GCodeWriter.py b/plugins/GCodeWriter/GCodeWriter.py index c80d8e610a..4eb1f89134 100644 --- a/plugins/GCodeWriter/GCodeWriter.py +++ b/plugins/GCodeWriter/GCodeWriter.py @@ -69,8 +69,8 @@ class GCodeWriter(MeshWriter): prefix_length = len(prefix) global_stack = Application.getInstance().getGlobalContainerStack() - container_with_settings = global_stack.getContainers()[1] - serialized = container_with_settings.serialize() + container_with_profile = global_stack.findContainer({"type": "quality"}) + serialized = container_with_profile.serialize() # Escape characters that have a special meaning in g-code comments. pattern = re.compile("|".join(GCodeWriter.escape_characters.keys())) From 93cdce7b3360b2b285ca32f8b7cf7ba7522381a9 Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Fri, 24 Jun 2016 16:01:47 +0200 Subject: [PATCH 4/7] GCodeProfileReader: Fixing read of profiles from GCode --- plugins/GCodeProfileReader/GCodeProfileReader.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/GCodeProfileReader/GCodeProfileReader.py b/plugins/GCodeProfileReader/GCodeProfileReader.py index 5915395005..1ce1473582 100644 --- a/plugins/GCodeProfileReader/GCodeProfileReader.py +++ b/plugins/GCodeProfileReader/GCodeProfileReader.py @@ -75,15 +75,16 @@ class GCodeProfileReader(ProfileReader): # Create an empty profile - the id will be changed later profile = InstanceContainer("") - profile.addMetaDataEntry("type", "quality") try: profile.deserialize(serialized) except Exception as e: # Not a valid g-code file. Logger.log("e", "Unable to serialise the profile: %s", str(e)) return None + profile.addMetaDataEntry("type", "quality") + #Creating a unique name using the filename of the GCode - new_name = catalog.i18nc("@label", "Custom profile (%s)") %(os.path.splitext(os.path.basename(file_name))[0]) + new_name = catalog.i18nc("@label", "G-Code-imported profile") profile.setName(new_name) profile._id = new_name From be4cf0083512a1e5cc67a27bfe9c692f4f7a7b7e Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Tue, 5 Jul 2016 18:22:56 +0200 Subject: [PATCH 5/7] BQ Hephestos2: Heat up nozzle while leveling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Saves time and preheats the nozzle to the correct temperature (set by Cura). Btw. the BQ support explained me the reason why they are assuming 210°C needs to set here. The reason is that the printer is just meant to be used with PLA, so they are only expecting to use exactly 210°C. Just explained them why this is incorrect when think about the possibility that Cura can set the temperature on it's own. --- resources/definitions/bq_hephestos_2.def.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/definitions/bq_hephestos_2.def.json b/resources/definitions/bq_hephestos_2.def.json index 374e41f93c..51777ff83e 100644 --- a/resources/definitions/bq_hephestos_2.def.json +++ b/resources/definitions/bq_hephestos_2.def.json @@ -14,7 +14,7 @@ }, "overrides": { - "machine_start_gcode": { "default_value": "; -- START GCODE --\nM800 ; Custom GCODE to fire start print procedure\nM109 S{material_print_temperature} ;Makes sure the temperature is correct before printing\n; -- end of START GCODE --" }, + "machine_start_gcode": { "default_value": "; -- START GCODE --\nM104 S{material_print_temperature} ; Heat up extruder while leveling\nM800 ; Custom GCODE to fire start print procedure\nM109 S{material_print_temperature} ; Makes sure the temperature is correct before printing\n; -- end of START GCODE --" }, "machine_end_gcode": { "default_value": "; -- END GCODE --\nM801 ; Custom GCODE to fire end print procedure\n; -- end of END GCODE --" }, "machine_width": { "default_value": 210 }, "machine_depth": { "default_value": 297 }, From 25c81ce1f86a3be41720b9e5689a490aed7ea7c8 Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Tue, 5 Jul 2016 18:55:13 +0200 Subject: [PATCH 6/7] Just a little typo --- plugins/SliceInfoPlugin/SliceInfo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/SliceInfoPlugin/SliceInfo.py b/plugins/SliceInfoPlugin/SliceInfo.py index f19a20c2b0..2751173a1c 100644 --- a/plugins/SliceInfoPlugin/SliceInfo.py +++ b/plugins/SliceInfoPlugin/SliceInfo.py @@ -55,7 +55,7 @@ class SliceInfo(Extension): print_information = Application.getInstance().getPrintInformation() material_radius = 0.5 * global_container_stack.getProperty("material_diameter", "value") - # TODO; Send material per extruder instead of mashing it on a pile + # TODO: Send material per extruder instead of mashing it on a pile material_used = math.pi * material_radius * material_radius * sum(print_information.materialAmounts) #Volume of all materials used # Get model information (bounding boxes, hashes and transformation matrix) From c06e5f4d39af1faedf24fd26b25beeb2f4dd1a9b Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Tue, 5 Jul 2016 21:58:47 +0200 Subject: [PATCH 7/7] Remove unused name/id when importing a profile from a gcode file A unique name will be set from the filename by ContainerRegistry CURA-1615 --- plugins/GCodeProfileReader/GCodeProfileReader.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/plugins/GCodeProfileReader/GCodeProfileReader.py b/plugins/GCodeProfileReader/GCodeProfileReader.py index 1ce1473582..1e649b7dd4 100644 --- a/plugins/GCodeProfileReader/GCodeProfileReader.py +++ b/plugins/GCodeProfileReader/GCodeProfileReader.py @@ -73,7 +73,7 @@ class GCodeProfileReader(ProfileReader): serialized = pattern.sub(lambda m: GCodeProfileReader.escape_characters[re.escape(m.group(0))], serialized) Logger.log("i", "Serialized the following from %s: %s" %(file_name, repr(serialized))) - # Create an empty profile - the id will be changed later + # Create an empty profile - the id and name will be changed by the ContainerRegistry profile = InstanceContainer("") try: profile.deserialize(serialized) @@ -83,9 +83,4 @@ class GCodeProfileReader(ProfileReader): profile.addMetaDataEntry("type", "quality") - #Creating a unique name using the filename of the GCode - new_name = catalog.i18nc("@label", "G-Code-imported profile") - profile.setName(new_name) - profile._id = new_name - return profile