1 from __future__ import absolute_import
5 from Cura.util import profile
7 class gcodeGenerator(object):
9 self._feedPrint = profile.getProfileSettingFloat('print_speed') * 60
10 self._feedTravel = profile.getProfileSettingFloat('travel_speed') * 60
11 self._feedRetract = profile.getProfileSettingFloat('retraction_speed') * 60
12 filamentRadius = profile.getProfileSettingFloat('filament_diameter') / 2
13 filamentArea = math.pi * filamentRadius * filamentRadius
14 self._ePerMM = (profile.getProfileSettingFloat('nozzle_size') * 0.1) / filamentArea
20 self._list = ['G92 E0']
22 def setExtrusionRate(self, lineWidth, layerHeight):
23 filamentRadius = profile.getProfileSettingFloat('filament_diameter') / 2
24 filamentArea = math.pi * filamentRadius * filamentRadius
25 self._ePerMM = (lineWidth * layerHeight) / filamentArea
33 def addMove(self, x=None, y=None, z=None):
44 cmd += "F%d" % (self._feedTravel)
47 def addPrime(self, amount=5):
48 self._eValue += amount
49 self._list += ['G1 E%f F%f' % (self._eValue, self._feedRetract)]
51 def addRetract(self, amount=5):
52 self._eValue -= amount
53 self._list += ['G1 E%f F%f' % (self._eValue, self._feedRetract)]
55 def addExtrude(self, x=None, y=None, z=None):
68 self._eValue += math.sqrt((self._x - oldX) * (self._x - oldX) + (self._y - oldY) * (self._y - oldY)) * self._ePerMM
69 cmd += "E%f F%d" % (self._eValue, self._feedPrint)
72 def addCmd(self, cmd):