chiark / gitweb /
Added feature to load a profile from a sliced GCode file.
authorDaid <daid303@gmail.com>
Thu, 5 Jul 2012 06:46:41 +0000 (08:46 +0200)
committerDaid <daid303@gmail.com>
Thu, 5 Jul 2012 06:46:41 +0000 (08:46 +0200)
Cura/gui/mainWindow.py
Cura/util/profile.py
package.sh

index 77c16a9e5270c920ff30892f5fea0b0a51493dd0..29be141120eff862e626f4eb00f8c8465e819488 100644 (file)
@@ -53,6 +53,8 @@ class mainWindow(configBase.configWindowBase):
                self.Bind(wx.EVT_MENU, self.OnLoadProfile, i)
                i = fileMenu.Append(-1, 'Save Profile...')
                self.Bind(wx.EVT_MENU, self.OnSaveProfile, i)
+               i = fileMenu.Append(-1, 'Load Profile from GCode...')
+               self.Bind(wx.EVT_MENU, self.OnLoadProfileFromGcode, i)
                fileMenu.AppendSeparator()
                i = fileMenu.Append(-1, 'Reset Profile to default')
                self.Bind(wx.EVT_MENU, self.OnResetProfile, i)
@@ -256,6 +258,23 @@ class mainWindow(configBase.configWindowBase):
                        profile.loadGlobalProfile(profileFile)
                        self.updateProfileToControls()
                dlg.Destroy()
+
+       def OnLoadProfileFromGcode(self, e):
+               dlg=wx.FileDialog(self, "Select gcode file to load profile from", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
+               dlg.SetWildcard("gcode files (*.gcode)|*.gcode")
+               if dlg.ShowModal() == wx.ID_OK:
+                       gcodeFile = dlg.GetPath()
+                       f = open(gcodeFile, 'r')
+                       hasProfile = False
+                       for line in f:
+                               if line.startswith(';CURA_PROFILE_STRING:'):
+                                       profile.loadGlobalProfileFromString(line[line.find(':')+1:].strip())
+                                       hasProfile = True
+                       if hasProfile:
+                               self.updateProfileToControls()
+                       else:
+                               wx.MessageBox('No profile found in GCode file.\nThis feature only works with GCode files made by Cura 12.07 or newer.', 'Profile load error', wx.OK | wx.ICON_INFORMATION)
+               dlg.Destroy()
        
        def OnSaveProfile(self, e):
                dlg=wx.FileDialog(self, "Select profile file to save", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_SAVE)
index 8d7975ac58150ca49cad10e061c2ce13b5418b5c..f40f0e33a993cc930a72458a1760b34d944980b7 100644 (file)
@@ -435,6 +435,7 @@ def setAlterationFile(filename, value):
 ### Get the alteration file for output. (Used by Skeinforge)\r
 def getAlterationFileContents(filename):\r
        prefix = ''\r
+       postfix = ''\r
        alterationContents = getAlterationFile(filename)\r
        if filename == 'start.gcode':\r
                #For the start code, hack the temperature and the steps per E value into it. So the temperature is reached before the start code extrusion.\r
@@ -445,9 +446,12 @@ def getAlterationFileContents(filename):
                temp = getProfileSettingFloat('print_temperature')\r
                if temp > 0 and not '{print_temperature}' in alterationContents:\r
                        prefix += 'M109 S%f\n' % (temp)\r
+       elif filename == 'end.gcode':\r
+               #Append the profile string to the end of the GCode, so we can load it from the GCode file later.\r
+               postfix = ';CURA_PROFILE_STRING:%s\n' % (getGlobalProfileString())\r
        elif filename == 'replace.csv':\r
                #Always remove the extruder on/off M codes. These are no longer needed in 5D printing.\r
                prefix = 'M101\nM103\n'\r
        \r
-       return unicode(prefix + re.sub("\{[^\}]*\}", replaceTagMatch, alterationContents).rstrip() + '\n').encode('utf-8')\r
+       return unicode(prefix + re.sub("\{[^\}]*\}", replaceTagMatch, alterationContents).rstrip() + '\n' + postfix).encode('utf-8')\r
 \r
index 8f9955ff6196b2340e27660e723024719b205024..a84b8d7a12a961fad4b1158346a593864a95938a 100755 (executable)
@@ -16,7 +16,7 @@ BUILD_TARGET=${1:-win32}
 ##Do we need to create the final archive
 ARCHIVE_FOR_DISTRIBUTION=1
 ##Which version name are we appending to the final archive
-BUILD_NAME=RC4
+BUILD_NAME=12.07
 TARGET_DIR=${BUILD_TARGET}-Cura-${BUILD_NAME}
 
 ##Which versions of external programs to use