Add extrusion volume calculation for Slic3r gcode files

master
Bryan Mayland 2013-06-17 14:39:52 +00:00
parent 33731464e5
commit e32afe147a
2 changed files with 7 additions and 0 deletions

View File

@ -63,6 +63,8 @@ class GcodeManager:
dirty = True
if gcode.extrusionAmount:
analysisResult["filament"] = "%.2fm" % (gcode.extrusionAmount / 1000)
if gcode.extrusionVolume:
analysisResult["filament"] += " / %.2fcc" % gcode.extrusionVolume
dirty = True
if dirty:

View File

@ -37,6 +37,7 @@ class gcode(object):
self.regMatch = {}
self.layerList = []
self.extrusionAmount = 0
self.extrusionVolume = 0
self.totalMoveTimeMinute = 0
self.progressCallback = None
self._abort = False
@ -61,6 +62,7 @@ class gcode(object):
currentE = 0.0
totalExtrusion = 0.0
maxExtrusion = 0.0
extrusionDiameter = 0
currentExtruder = 0
extrudeAmountMultiply = 1.0
totalMoveTimeMinute = 0.0
@ -105,6 +107,8 @@ class gcode(object):
pathType = 'WALL-INNER'
elif comment == 'skirt':
pathType = 'SKIRT'
elif comment.startswith('filament_diameter = '):
filamentDiameter = int(line[line.find('=')+1:])
if comment.startswith('LAYER:'):
self.layerList.append(currentLayer)
currentLayer = []
@ -276,6 +280,7 @@ class gcode(object):
unknownMcodes[M] = True
self.layerList.append(currentLayer)
self.extrusionAmount = maxExtrusion
self.extrusionVolume = math.pi * math.pow(filamentDiameter / 2.0, 2) * maxExtrusion / 1000.0
self.totalMoveTimeMinute = totalMoveTimeMinute
def getCodeInt(self, line, code):