From 54825151577512803f908a982c8f762d2c64ae4a Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 17 Nov 2016 13:15:25 +0100 Subject: Importing profiles from g-code made by Cura 2.3 is now possible again CURA-2943 --- plugins/GCodeProfileReader/GCodeProfileReader.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'plugins/GCodeProfileReader') diff --git a/plugins/GCodeProfileReader/GCodeProfileReader.py b/plugins/GCodeProfileReader/GCodeProfileReader.py index 24c92d08e9..abfef6e296 100644 --- a/plugins/GCodeProfileReader/GCodeProfileReader.py +++ b/plugins/GCodeProfileReader/GCodeProfileReader.py @@ -70,10 +70,19 @@ class GCodeProfileReader(ProfileReader): json_data = json.loads(serialized) - profile_strings = [json_data["global_quality"]] - profile_strings.extend(json_data.get("extruder_quality", [])) - - return [readQualityProfileFromString(profile_string) for profile_string in profile_strings] + profiles = [] + global_profile = readQualityProfileFromString(json_data["global_quality"]) + + # This is a fix for profiles created with 2.3.0 For some reason it added the "extruder" property to the + # global profile. + # The fix is simple and safe, as a global profile should never have the extruder entry. + if global_profile.getMetaDataEntry("extruder", None) is not None: + global_profile.setMetaDataEntry("extruder", None) + profiles.append(global_profile) + + for profile_string in json_data.get("extruder_quality", []): + profiles.append(readQualityProfileFromString(profile_string)) + return profiles ## Unescape a string which has been escaped for use in a gcode comment. # -- cgit v1.2.3