"A class to alteration a skein of extrusions."
def __init__(self):
'Initialize.'
- self.distanceFeedRate = gcodec.DistanceFeedRate()
+ self.distanceFeedRate = gcodec.DistanceFeedRate()
self.lineIndex = 0
self.settingDictionary = None
if self.settingDictionary == None:
return self.distanceFeedRate.output.getvalue().replace('(<alterationDeleteThisPrefix/>)', '')
lines = archive.getTextLines(self.distanceFeedRate.output.getvalue())
- distanceFeedRate = gcodec.DistanceFeedRate()
+ distanceFeedRate = gcodec.DistanceFeedRate()
for line in lines:
if line.startswith('(<alterationDeleteThisPrefix/>)'):
line = self.getReplacedAlterationLine(line[len('(<alterationDeleteThisPrefix/>)') :])
self.lastZString = None
self.output = cStringIO.StringIO()
self.layerNr = 0
+ self.parsingAlteration = False
def getCraftedGcode( self, gcodeText ):
"Parse gcode text and store the gcode."
elif line.startswith('(<infill>'):
self.output.write(';TYPE:FILL\n');
elif line.startswith('(<alteration>'):
- self.output.write(';TYPE:CUSTOM\n');
+ self.output.write(';TYPE:CUSTOM X\n');
+ self.parsingAlteration = True
+ elif line.startswith('(</alteration>)'):
+ self.parsingAlteration = False
elif line.startswith('(<supportLayer>'):
self.output.write(';TYPE:SUPPORT\n');
elif line.startswith('(<layer>'):
#Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.\r
import __init__\r
\r
-import ConfigParser, os, traceback, math, re, zlib, base64\r
+import ConfigParser, os, traceback, math, re, zlib, base64, time\r
\r
#########################################################\r
## Default settings when none are found.\r
}\r
alterationDefault = {\r
#######################################################################################\r
- 'start.gcode': """;Start GCode\r
+ 'start.gcode': """;Sliced at: {day} {date} {time}\r
+;Basic settings: Layer height: {layer_height} Walls: {wall_thickness} Fill: {fill_density}\r
G21 ;metric values\r
G90 ;absolute positioning\r
M107 ;start with the fan off\r
#########################################################\r
def replaceTagMatch(m):\r
tag = m.group(0)[1:-1]\r
+ if tag == 'time':\r
+ return time.strftime('%H:%M:%S')\r
+ if tag == 'date':\r
+ return time.strftime('%d %b %Y')\r
+ if tag == 'day':\r
+ return time.strftime('%a')\r
if tag in ['print_speed', 'retraction_speed', 'travel_speed', 'max_z_speed', 'bottom_layer_speed', 'cool_min_feedrate']:\r
f = getProfileSettingFloat(tag) * 60\r
elif isProfileSetting(tag):\r