From: jbheren Date: Wed, 27 Nov 2013 13:40:22 +0000 (+0100) Subject: Issue #459 fix proposal X-Git-Tag: 14.01~53^2^2 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=50dd28b79af2c0d360cfa065091d46b524d1cccf;p=cura.git Issue #459 fix proposal --- diff --git a/Cura/cura.py b/Cura/cura.py index 2172a4bf..9beba7b0 100644 --- a/Cura/cura.py +++ b/Cura/cura.py @@ -54,6 +54,9 @@ def main(): scene.add(m) slicer.runSlicer(scene) slicer.wait() + # ISSUE 459 - output gcode without Print time - START + profile.replaceGCodeTagsFromSlicer(slicer.getGCodeFilename(), slicer) + # ISSUE 459 - output gcode without Print time - END if options.output: shutil.copyfile(slicer.getGCodeFilename(), options.output) diff --git a/Cura/util/profile.py b/Cura/util/profile.py index 74ae3a43..889cc1b0 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -918,6 +918,22 @@ def replaceGCodeTags(filename, gcodeInt): f.write(data) f.close() +# ISSUE 459 - output gcode without Print time - START +def replaceGCodeTagsFromSlicer(filename, slicerInt): + f = open(filename, 'r+') + data = f.read(2048) + data = data.replace('#P_TIME#', slicerInt.getPrintTime()) + data = data.replace('#F_AMNT#', slicerInt.getFilamentAmount()) + data = data.replace('#F_WGHT#', ('%8.2f' % (float(slicerInt.getFilamentWeight()) * 1000))[-8:]) + cost = slicerInt.getFilamentCost() + if cost is None: + cost = 'Unknown' + data = data.replace('#F_COST#', ('%8s' % (cost.split(' ')[0]))[-8:]) + f.seek(0) + f.write(data) + f.close() +# ISSUE 459 - output gcode without Print time - END + ### Get aleration raw contents. (Used internally in Cura) def getAlterationFile(filename): if filename in tempOverride: