Remove use of logfile to store model errors. Added print time and filament usage to comments in start code of resulting GCode file.
This commit is contained in:
parent
96d38d4312
commit
ad48bc6484
4 changed files with 41 additions and 15 deletions
|
@ -209,7 +209,6 @@ class previewPanel(wx.Panel):
|
||||||
obj.filename = filelist[idx]
|
obj.filename = filelist[idx]
|
||||||
|
|
||||||
self.gcodeFilename = sliceRun.getExportFilename(filelist[0])
|
self.gcodeFilename = sliceRun.getExportFilename(filelist[0])
|
||||||
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()
|
||||||
|
@ -246,21 +245,20 @@ class previewPanel(wx.Panel):
|
||||||
self.gcodeDirty = False
|
self.gcodeDirty = False
|
||||||
self.gcode = gcode
|
self.gcode = gcode
|
||||||
self.gcodeDirty = True
|
self.gcodeDirty = True
|
||||||
wx.CallAfter(self.updateToolbar)
|
|
||||||
wx.CallAfter(self.glCanvas.Refresh)
|
|
||||||
elif not os.path.isfile(self.gcodeFilename):
|
|
||||||
self.gcode = None
|
|
||||||
|
|
||||||
if os.path.isfile(self.logFilename):
|
|
||||||
errorList = []
|
errorList = []
|
||||||
for line in open(self.logFilename, "rt"):
|
for line in open(self.gcodeFilename, "rt"):
|
||||||
res = re.search('Model error\(([a-z ]*)\): \(([0-9\.\-e]*), ([0-9\.\-e]*), ([0-9\.\-e]*)\) \(([0-9\.\-e]*), ([0-9\.\-e]*), ([0-9\.\-e]*)\)', line)
|
res = re.search(';Model error\(([a-z ]*)\): \(([0-9\.\-e]*), ([0-9\.\-e]*), ([0-9\.\-e]*)\) \(([0-9\.\-e]*), ([0-9\.\-e]*), ([0-9\.\-e]*)\)', line)
|
||||||
if res != None:
|
if res != None:
|
||||||
v1 = util3d.Vector3(float(res.group(2)), float(res.group(3)), float(res.group(4)))
|
v1 = util3d.Vector3(float(res.group(2)), float(res.group(3)), float(res.group(4)))
|
||||||
v2 = util3d.Vector3(float(res.group(5)), float(res.group(6)), float(res.group(7)))
|
v2 = util3d.Vector3(float(res.group(5)), float(res.group(6)), float(res.group(7)))
|
||||||
errorList.append([v1, v2])
|
errorList.append([v1, v2])
|
||||||
self.errorList = errorList
|
self.errorList = errorList
|
||||||
|
|
||||||
|
wx.CallAfter(self.updateToolbar)
|
||||||
wx.CallAfter(self.glCanvas.Refresh)
|
wx.CallAfter(self.glCanvas.Refresh)
|
||||||
|
elif not os.path.isfile(self.gcodeFilename):
|
||||||
|
self.gcode = None
|
||||||
|
|
||||||
def loadProgress(self, progress):
|
def loadProgress(self, progress):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -1018,6 +1018,7 @@ class ProjectSliceProgressWindow(wx.Frame):
|
||||||
cost = gcode.calculateCost()
|
cost = gcode.calculateCost()
|
||||||
if cost != False:
|
if cost != False:
|
||||||
status += "\nCost: %s" % (cost)
|
status += "\nCost: %s" % (cost)
|
||||||
|
profile.replaceGCodeTags(self.resultFilename, gcode)
|
||||||
wx.CallAfter(self.statusText.SetLabel, status)
|
wx.CallAfter(self.statusText.SetLabel, status)
|
||||||
wx.CallAfter(self.OnSliceDone)
|
wx.CallAfter(self.OnSliceDone)
|
||||||
|
|
||||||
|
|
|
@ -156,17 +156,19 @@ class WorkerThread(threading.Thread):
|
||||||
return
|
return
|
||||||
line = p.stdout.readline()
|
line = p.stdout.readline()
|
||||||
self.returnCode = p.wait()
|
self.returnCode = p.wait()
|
||||||
logfile = open(sliceRun.getExportFilename(self.filelist[self.fileIdx], "log"), "w")
|
|
||||||
for logLine in self.progressLog:
|
|
||||||
logfile.write(logLine)
|
|
||||||
logfile.write('\n')
|
|
||||||
logfile.close()
|
|
||||||
self.fileIdx += 1
|
self.fileIdx += 1
|
||||||
if self.fileIdx == len(self.cmdList):
|
if self.fileIdx == len(self.cmdList):
|
||||||
if len(self.filelist) > 1:
|
if len(self.filelist) > 1:
|
||||||
self._stitchMultiExtruder()
|
self._stitchMultiExtruder()
|
||||||
|
gcodeFilename = sliceRun.getExportFilename(self.filelist[0])
|
||||||
|
gcodefile = open(gcodeFilename, "a")
|
||||||
|
for logLine in self.progressLog:
|
||||||
|
if logLine.startswith('Model error('):
|
||||||
|
gcodefile.write(';%s\n' % (logLine))
|
||||||
|
gcodefile.close()
|
||||||
self.gcode = gcodeInterpreter.gcode()
|
self.gcode = gcodeInterpreter.gcode()
|
||||||
self.gcode.load(sliceRun.getExportFilename(self.filelist[0]))
|
self.gcode.load(gcodeFilename)
|
||||||
|
profile.replaceGCodeTags(gcodeFilename, self.gcode)
|
||||||
wx.CallAfter(self.notifyWindow.OnSliceDone, self)
|
wx.CallAfter(self.notifyWindow.OnSliceDone, self)
|
||||||
else:
|
else:
|
||||||
self.run()
|
self.run()
|
||||||
|
|
|
@ -83,6 +83,9 @@ alterationDefault = {
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
'start.gcode': """;Sliced at: {day} {date} {time}
|
'start.gcode': """;Sliced at: {day} {date} {time}
|
||||||
;Basic settings: Layer height: {layer_height} Walls: {wall_thickness} Fill: {fill_density}
|
;Basic settings: Layer height: {layer_height} Walls: {wall_thickness} Fill: {fill_density}
|
||||||
|
;Print time: {print_time}
|
||||||
|
;Filament used: {filament_amount}m {filament_weight}g
|
||||||
|
;Filament cost: {filament_cost}
|
||||||
G21 ;metric values
|
G21 ;metric values
|
||||||
G90 ;absolute positioning
|
G90 ;absolute positioning
|
||||||
M107 ;start with the fan off
|
M107 ;start with the fan off
|
||||||
|
@ -392,6 +395,14 @@ def replaceTagMatch(m):
|
||||||
return time.strftime('%d %b %Y')
|
return time.strftime('%d %b %Y')
|
||||||
if tag == 'day':
|
if tag == 'day':
|
||||||
return time.strftime('%a')
|
return time.strftime('%a')
|
||||||
|
if tag == 'print_time':
|
||||||
|
return '#P_TIME#'
|
||||||
|
if tag == 'filament_amount':
|
||||||
|
return '#F_AMNT#'
|
||||||
|
if tag == 'filament_weight':
|
||||||
|
return '#F_WGHT#'
|
||||||
|
if tag == 'filament_cost':
|
||||||
|
return '#F_COST#'
|
||||||
if tag in ['print_speed', 'retraction_speed', 'travel_speed', 'max_z_speed', 'bottom_layer_speed', 'cool_min_feedrate']:
|
if tag in ['print_speed', 'retraction_speed', 'travel_speed', 'max_z_speed', 'bottom_layer_speed', 'cool_min_feedrate']:
|
||||||
f = getProfileSettingFloat(tag) * 60
|
f = getProfileSettingFloat(tag) * 60
|
||||||
elif isProfileSetting(tag):
|
elif isProfileSetting(tag):
|
||||||
|
@ -404,6 +415,20 @@ def replaceTagMatch(m):
|
||||||
return str(int(f))
|
return str(int(f))
|
||||||
return str(f)
|
return str(f)
|
||||||
|
|
||||||
|
def replaceGCodeTags(filename, gcodeInt):
|
||||||
|
f = open(filename, 'r+')
|
||||||
|
data = f.read(2048)
|
||||||
|
data = data.replace('#P_TIME#', ('%5d:%02d' % (int(gcodeInt.totalMoveTimeMinute / 60), int(gcodeInt.totalMoveTimeMinute % 60)))[-8:])
|
||||||
|
data = data.replace('#F_AMNT#', ('%8.2f' % (gcodeInt.extrusionAmount / 1000))[-8:])
|
||||||
|
data = data.replace('#F_WGHT#', ('%8.2f' % (gcodeInt.calculateWeight() * 1000))[-8:])
|
||||||
|
cost = gcodeInt.calculateCost()
|
||||||
|
if cost == False:
|
||||||
|
cost = 'Unknown'
|
||||||
|
data = data.replace('#F_COST#', ('%8s' % (cost.split(' ')[0]))[-8:])
|
||||||
|
f.seek(0)
|
||||||
|
f.write(data)
|
||||||
|
f.close()
|
||||||
|
|
||||||
### Get aleration raw contents. (Used internally in Cura)
|
### Get aleration raw contents. (Used internally in Cura)
|
||||||
def getAlterationFile(filename):
|
def getAlterationFile(filename):
|
||||||
#Check if we have a configuration file loaded, else load the default.
|
#Check if we have a configuration file loaded, else load the default.
|
||||||
|
|
Loading…
Reference in a new issue