chiark / gitweb /
Issue #459 fix proposal
authorjbheren <contact@jbheren.com>
Wed, 27 Nov 2013 13:40:22 +0000 (14:40 +0100)
committerjbheren <contact@jbheren.com>
Wed, 27 Nov 2013 13:40:22 +0000 (14:40 +0100)
Cura/cura.py
Cura/util/profile.py

index 2172a4bfa5959fbbc2891f85f3f927dfff3a6310..9beba7b09c81439bbbdd915143d6937a9bf32853 100644 (file)
@@ -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)
index 74ae3a43db0eb25c04ec41aae53049f8fc312603..889cc1b074440bf69fca12b1a02f81ece4e57673 100644 (file)
@@ -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: