mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-05 19:36:07 +08:00
Use a function to generate the "_export.xxx" filename
This commit is contained in:
parent
16c043e469
commit
eb44963079
@ -18,6 +18,7 @@ from gui import projectPlanner
|
|||||||
from gui import icon
|
from gui import icon
|
||||||
from util import profile
|
from util import profile
|
||||||
from util import version
|
from util import version
|
||||||
|
from util import sliceRun
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
app = wx.App(False)
|
app = wx.App(False)
|
||||||
@ -333,10 +334,10 @@ class mainWindow(configBase.configWindowBase):
|
|||||||
if len(self.filelist) < 1:
|
if len(self.filelist) < 1:
|
||||||
wx.MessageBox('You need to load a file and slice it before you can print it.', 'Print error', wx.OK | wx.ICON_INFORMATION)
|
wx.MessageBox('You need to load a file and slice it before you can print it.', 'Print error', wx.OK | wx.ICON_INFORMATION)
|
||||||
return
|
return
|
||||||
if not os.path.exists(self.filelist[0][: self.filelist[0].rfind('.')] + "_export.gcode"):
|
if not os.path.exists(sliceRun.getExportFilename(self.filelist[0])):
|
||||||
wx.MessageBox('You need to slice the file to GCode before you can print it.', 'Print error', wx.OK | wx.ICON_INFORMATION)
|
wx.MessageBox('You need to slice the file to GCode before you can print it.', 'Print error', wx.OK | wx.ICON_INFORMATION)
|
||||||
return
|
return
|
||||||
printWindow.printFile(self.filelist[0][: self.filelist[0].rfind('.')] + "_export.gcode")
|
printWindow.printFile(sliceRun.getExportFilename(self.filelist[0]))
|
||||||
|
|
||||||
def OnExpertOpen(self, e):
|
def OnExpertOpen(self, e):
|
||||||
ecw = expertConfig.expertConfigWindow()
|
ecw = expertConfig.expertConfigWindow()
|
||||||
|
@ -21,6 +21,7 @@ from util import profile
|
|||||||
from util import gcodeInterpreter
|
from util import gcodeInterpreter
|
||||||
from util import stl
|
from util import stl
|
||||||
from util import util3d
|
from util import util3d
|
||||||
|
from util import sliceRun
|
||||||
|
|
||||||
class previewObject():
|
class previewObject():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -207,8 +208,8 @@ class previewPanel(wx.Panel):
|
|||||||
self.logFileTime = None
|
self.logFileTime = None
|
||||||
obj.filename = filelist[idx]
|
obj.filename = filelist[idx]
|
||||||
|
|
||||||
self.gcodeFilename = filelist[0][: filelist[0].rfind('.')] + "_export.gcode"
|
self.gcodeFilename = sliceRun.getExportFilename(filelist[0])
|
||||||
self.logFilename = filelist[0][: filelist[0].rfind('.')] + "_export.log"
|
self.logFilename = sliceRun.getExportFilename(filelist[0], "log")
|
||||||
#Do the STL file loading in a background thread so we don't block the UI.
|
#Do the STL file loading in a background thread so we don't block the UI.
|
||||||
if self.loadThread != None and self.loadThread.isAlive():
|
if self.loadThread != None and self.loadThread.isAlive():
|
||||||
self.loadThread.join()
|
self.loadThread.join()
|
||||||
|
@ -893,7 +893,7 @@ class ProjectSliceProgressWindow(wx.Frame):
|
|||||||
profile.resetTempOverride()
|
profile.resetTempOverride()
|
||||||
|
|
||||||
if not action.usePreviousSlice:
|
if not action.usePreviousSlice:
|
||||||
f = open(action.filename[: action.filename.rfind('.')] + "_export.project_tmp", "r")
|
f = open(sliceRun.getExportFilename(action.filename, "project_tmp"), "r")
|
||||||
data = f.read(4096)
|
data = f.read(4096)
|
||||||
while data != '':
|
while data != '':
|
||||||
resultFile.write(data)
|
resultFile.write(data)
|
||||||
@ -902,7 +902,7 @@ class ProjectSliceProgressWindow(wx.Frame):
|
|||||||
savedCenterX = action.centerX
|
savedCenterX = action.centerX
|
||||||
savedCenterY = action.centerY
|
savedCenterY = action.centerY
|
||||||
else:
|
else:
|
||||||
f = open(action.filename[: action.filename.rfind('.')] + "_export.project_tmp", "r")
|
f = open(sliceRun.getExportFilename(action.filename, "project_tmp"), "r")
|
||||||
for line in f:
|
for line in f:
|
||||||
if line[0] != ';':
|
if line[0] != ';':
|
||||||
if 'X' in line:
|
if 'X' in line:
|
||||||
@ -913,7 +913,7 @@ class ProjectSliceProgressWindow(wx.Frame):
|
|||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
if not action.leaveResultForNextSlice:
|
if not action.leaveResultForNextSlice:
|
||||||
os.remove(action.filename[: action.filename.rfind('.')] + "_export.project_tmp")
|
os.remove(sliceRun.getExportFilename(action.filename, "project_tmp"))
|
||||||
|
|
||||||
wx.CallAfter(self.progressGauge.SetValue, 10000)
|
wx.CallAfter(self.progressGauge.SetValue, 10000)
|
||||||
self.totalDoneFactor = 0.0
|
self.totalDoneFactor = 0.0
|
||||||
|
@ -14,6 +14,7 @@ from gui import printWindow
|
|||||||
from gui import icon
|
from gui import icon
|
||||||
from util import profile
|
from util import profile
|
||||||
from util import version
|
from util import version
|
||||||
|
from util import sliceRun
|
||||||
|
|
||||||
class simpleModeWindow(configBase.configWindowBase):
|
class simpleModeWindow(configBase.configWindowBase):
|
||||||
"Main user interface window for Quickprint mode"
|
"Main user interface window for Quickprint mode"
|
||||||
@ -276,10 +277,10 @@ class simpleModeWindow(configBase.configWindowBase):
|
|||||||
if len(self.filelist) < 1:
|
if len(self.filelist) < 1:
|
||||||
wx.MessageBox('You need to load a file and slice it before you can print it.', 'Print error', wx.OK | wx.ICON_INFORMATION)
|
wx.MessageBox('You need to load a file and slice it before you can print it.', 'Print error', wx.OK | wx.ICON_INFORMATION)
|
||||||
return
|
return
|
||||||
if not os.path.exists(self.filelist[0][: self.filelist[0].rfind('.')] + "_export.gcode"):
|
if not os.path.exists(sliceRun.getExportFilename(self.filelist[0])):
|
||||||
wx.MessageBox('You need to slice the file to GCode before you can print it.', 'Print error', wx.OK | wx.ICON_INFORMATION)
|
wx.MessageBox('You need to slice the file to GCode before you can print it.', 'Print error', wx.OK | wx.ICON_INFORMATION)
|
||||||
return
|
return
|
||||||
printWindow.printFile(self.filelist[0][: self.filelist[0].rfind('.')] + "_export.gcode")
|
printWindow.printFile(sliceRun.getExportFilename(self.filelist[0]))
|
||||||
|
|
||||||
def OnNormalSwitch(self, e):
|
def OnNormalSwitch(self, e):
|
||||||
from gui import mainWindow
|
from gui import mainWindow
|
||||||
|
@ -68,7 +68,7 @@ class sliceProgessPanel(wx.Panel):
|
|||||||
LogWindow('\n'.join(self.progressLog))
|
LogWindow('\n'.join(self.progressLog))
|
||||||
|
|
||||||
def OnOpenFileLocation(self, e):
|
def OnOpenFileLocation(self, e):
|
||||||
exporer.openExporer(self.filelist[0][: self.filelist[0].rfind('.')] + "_export.gcode")
|
exporer.openExporer(sliceRun.getExportFilename(self.filelist[0]))
|
||||||
|
|
||||||
def OnSliceDone(self, result):
|
def OnSliceDone(self, result):
|
||||||
self.progressGauge.Destroy()
|
self.progressGauge.Destroy()
|
||||||
@ -145,7 +145,7 @@ class WorkerThread(threading.Thread):
|
|||||||
return
|
return
|
||||||
line = p.stdout.readline()
|
line = p.stdout.readline()
|
||||||
self.returnCode = p.wait()
|
self.returnCode = p.wait()
|
||||||
logfile = open(self.filelist[self.fileIdx][: self.filelist[self.fileIdx].rfind('.')] + "_export.log", "w")
|
logfile = open(sliceRun.getExportFilename(self.filelist[self.fileIdx], "log"), "w")
|
||||||
for logLine in self.progressLog:
|
for logLine in self.progressLog:
|
||||||
logfile.write(logLine)
|
logfile.write(logLine)
|
||||||
logfile.write('\n')
|
logfile.write('\n')
|
||||||
@ -155,19 +155,19 @@ class WorkerThread(threading.Thread):
|
|||||||
if len(self.filelist) > 1:
|
if len(self.filelist) > 1:
|
||||||
self._stitchMultiExtruder()
|
self._stitchMultiExtruder()
|
||||||
self.gcode = gcodeInterpreter.gcode()
|
self.gcode = gcodeInterpreter.gcode()
|
||||||
self.gcode.load(self.filelist[0][:self.filelist[0].rfind('.')]+'_export.gcode')
|
self.gcode.load(sliceRun.getExportFilename(self.filelist[0]))
|
||||||
wx.CallAfter(self.notifyWindow.OnSliceDone, self)
|
wx.CallAfter(self.notifyWindow.OnSliceDone, self)
|
||||||
else:
|
else:
|
||||||
self.run()
|
self.run()
|
||||||
|
|
||||||
def _stitchMultiExtruder(self):
|
def _stitchMultiExtruder(self):
|
||||||
files = []
|
files = []
|
||||||
resultFile = open(self.filelist[0][:self.filelist[0].rfind('.')]+'_export.gcode', "w")
|
resultFile = open(sliceRun.getExportFilename(self.filelist[0]), "w")
|
||||||
resultFile.write(';TYPE:CUSTOM\n')
|
resultFile.write(';TYPE:CUSTOM\n')
|
||||||
resultFile.write(profile.getAlterationFileContents('start.gcode'))
|
resultFile.write(profile.getAlterationFileContents('start.gcode'))
|
||||||
for filename in self.filelist:
|
for filename in self.filelist:
|
||||||
if os.path.isfile(filename[:filename.rfind('.')]+'_export.multi_extrude_tmp'):
|
if os.path.isfile(sliceRun.getExportFilename(filename, 'multi_extrude_tmp')):
|
||||||
files.append(open(filename[:filename.rfind('.')]+'_export.multi_extrude_tmp', "r"))
|
files.append(open(sliceRun.getExportFilename(filename, 'multi_extrude_tmp'), "r"))
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ class WorkerThread(threading.Thread):
|
|||||||
for f in files:
|
for f in files:
|
||||||
f.close()
|
f.close()
|
||||||
for filename in self.filelist:
|
for filename in self.filelist:
|
||||||
os.remove(filename[:filename.rfind('.')]+'_export.multi_extrude_tmp')
|
os.remove(sliceRun.getExportFilename(filename, 'multi_extrude_tmp'))
|
||||||
resultFile.write(';TYPE:CUSTOM\n')
|
resultFile.write(';TYPE:CUSTOM\n')
|
||||||
resultFile.write(profile.getAlterationFileContents('end.gcode'))
|
resultFile.write(profile.getAlterationFileContents('end.gcode'))
|
||||||
resultFile.close()
|
resultFile.close()
|
||||||
|
@ -83,6 +83,9 @@ def runSlice(fileNames):
|
|||||||
else:
|
else:
|
||||||
subprocess.call([pypyExe, os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", os.path.split(sys.argv[0])[1])), '-p', profile.getGlobalProfileString(), fileName])
|
subprocess.call([pypyExe, os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", os.path.split(sys.argv[0])[1])), '-p', profile.getGlobalProfileString(), fileName])
|
||||||
|
|
||||||
|
def getExportFilename(filename, ext = "gcode"):
|
||||||
|
return "%s_export.%s" % (filename[: filename.rfind('.')], ext)
|
||||||
|
|
||||||
def getSliceCommand(filename):
|
def getSliceCommand(filename):
|
||||||
if profile.getPreference('slicer').startswith('Slic3r') and getSlic3rExe() != False:
|
if profile.getPreference('slicer').startswith('Slic3r') and getSlic3rExe() != False:
|
||||||
slic3rExe = getSlic3rExe()
|
slic3rExe = getSlic3rExe()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user