Added slice date/time and basic settings to start GCode. And made export preserve lines that only had comments.

This commit is contained in:
Daid 2012-05-20 11:15:20 +02:00
parent 6fbc7e4d91
commit 3192b0ac71
4 changed files with 17 additions and 5 deletions

View file

@ -164,7 +164,7 @@ class AlterationSkein:
"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
@ -211,7 +211,7 @@ class AlterationSkein:
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/>)') :])

View file

@ -398,6 +398,7 @@ class ExportSkein:
'Parse a gcode line.'
splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
if len(splitLine) < 1:
self.addLine(line)
return
firstWord = splitLine[0]
if firstWord == '(</crafting>)':

View file

@ -69,6 +69,7 @@ class GcodeSmallSkein:
self.lastZString = None
self.output = cStringIO.StringIO()
self.layerNr = 0
self.parsingAlteration = False
def getCraftedGcode( self, gcodeText ):
"Parse gcode text and store the gcode."
@ -127,7 +128,10 @@ class GcodeSmallSkein:
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>'):

View file

@ -3,7 +3,7 @@ from __future__ import division
#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.
import __init__
import ConfigParser, os, traceback, math, re, zlib, base64
import ConfigParser, os, traceback, math, re, zlib, base64, time
#########################################################
## Default settings when none are found.
@ -76,7 +76,8 @@ profileDefaultSettings = {
}
alterationDefault = {
#######################################################################################
'start.gcode': """;Start GCode
'start.gcode': """;Sliced at: {day} {date} {time}
;Basic settings: Layer height: {layer_height} Walls: {wall_thickness} Fill: {fill_density}
G21 ;metric values
G90 ;absolute positioning
M107 ;start with the fan off
@ -364,6 +365,12 @@ def calculateSolidLayerCount():
#########################################################
def replaceTagMatch(m):
tag = m.group(0)[1:-1]
if tag == 'time':
return time.strftime('%H:%M:%S')
if tag == 'date':
return time.strftime('%d %b %Y')
if tag == 'day':
return time.strftime('%a')
if tag in ['print_speed', 'retraction_speed', 'travel_speed', 'max_z_speed', 'bottom_layer_speed', 'cool_min_feedrate']:
f = getProfileSettingFloat(tag) * 60
elif isProfileSetting(tag):