mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-04 13:50:35 +08:00
Added feature to load a profile from a sliced GCode file.
This commit is contained in:
parent
1070cbf99e
commit
e332443bb4
@ -53,6 +53,8 @@ class mainWindow(configBase.configWindowBase):
|
|||||||
self.Bind(wx.EVT_MENU, self.OnLoadProfile, i)
|
self.Bind(wx.EVT_MENU, self.OnLoadProfile, i)
|
||||||
i = fileMenu.Append(-1, 'Save Profile...')
|
i = fileMenu.Append(-1, 'Save Profile...')
|
||||||
self.Bind(wx.EVT_MENU, self.OnSaveProfile, i)
|
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()
|
fileMenu.AppendSeparator()
|
||||||
i = fileMenu.Append(-1, 'Reset Profile to default')
|
i = fileMenu.Append(-1, 'Reset Profile to default')
|
||||||
self.Bind(wx.EVT_MENU, self.OnResetProfile, i)
|
self.Bind(wx.EVT_MENU, self.OnResetProfile, i)
|
||||||
@ -256,6 +258,23 @@ class mainWindow(configBase.configWindowBase):
|
|||||||
profile.loadGlobalProfile(profileFile)
|
profile.loadGlobalProfile(profileFile)
|
||||||
self.updateProfileToControls()
|
self.updateProfileToControls()
|
||||||
dlg.Destroy()
|
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):
|
def OnSaveProfile(self, e):
|
||||||
dlg=wx.FileDialog(self, "Select profile file to save", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_SAVE)
|
dlg=wx.FileDialog(self, "Select profile file to save", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_SAVE)
|
||||||
|
@ -435,6 +435,7 @@ def setAlterationFile(filename, value):
|
|||||||
### Get the alteration file for output. (Used by Skeinforge)
|
### Get the alteration file for output. (Used by Skeinforge)
|
||||||
def getAlterationFileContents(filename):
|
def getAlterationFileContents(filename):
|
||||||
prefix = ''
|
prefix = ''
|
||||||
|
postfix = ''
|
||||||
alterationContents = getAlterationFile(filename)
|
alterationContents = getAlterationFile(filename)
|
||||||
if filename == 'start.gcode':
|
if filename == 'start.gcode':
|
||||||
#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.
|
#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.
|
||||||
@ -445,9 +446,12 @@ def getAlterationFileContents(filename):
|
|||||||
temp = getProfileSettingFloat('print_temperature')
|
temp = getProfileSettingFloat('print_temperature')
|
||||||
if temp > 0 and not '{print_temperature}' in alterationContents:
|
if temp > 0 and not '{print_temperature}' in alterationContents:
|
||||||
prefix += 'M109 S%f\n' % (temp)
|
prefix += 'M109 S%f\n' % (temp)
|
||||||
|
elif filename == 'end.gcode':
|
||||||
|
#Append the profile string to the end of the GCode, so we can load it from the GCode file later.
|
||||||
|
postfix = ';CURA_PROFILE_STRING:%s\n' % (getGlobalProfileString())
|
||||||
elif filename == 'replace.csv':
|
elif filename == 'replace.csv':
|
||||||
#Always remove the extruder on/off M codes. These are no longer needed in 5D printing.
|
#Always remove the extruder on/off M codes. These are no longer needed in 5D printing.
|
||||||
prefix = 'M101\nM103\n'
|
prefix = 'M101\nM103\n'
|
||||||
|
|
||||||
return unicode(prefix + re.sub("\{[^\}]*\}", replaceTagMatch, alterationContents).rstrip() + '\n').encode('utf-8')
|
return unicode(prefix + re.sub("\{[^\}]*\}", replaceTagMatch, alterationContents).rstrip() + '\n' + postfix).encode('utf-8')
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ BUILD_TARGET=${1:-win32}
|
|||||||
##Do we need to create the final archive
|
##Do we need to create the final archive
|
||||||
ARCHIVE_FOR_DISTRIBUTION=1
|
ARCHIVE_FOR_DISTRIBUTION=1
|
||||||
##Which version name are we appending to the final archive
|
##Which version name are we appending to the final archive
|
||||||
BUILD_NAME=RC4
|
BUILD_NAME=12.07
|
||||||
TARGET_DIR=${BUILD_TARGET}-Cura-${BUILD_NAME}
|
TARGET_DIR=${BUILD_TARGET}-Cura-${BUILD_NAME}
|
||||||
|
|
||||||
##Which versions of external programs to use
|
##Which versions of external programs to use
|
||||||
|
Loading…
x
Reference in New Issue
Block a user