Add support for {filename} tag in gcode.
parent
ad48bc6484
commit
9fd5a9b020
|
@ -93,9 +93,9 @@ __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agp
|
|||
|
||||
def getCraftedText(fileName, text='', repository=None):
|
||||
'Alteration a gcode linear move text.'
|
||||
return getCraftedTextFromText(archive.getTextIfEmpty(fileName, text), repository)
|
||||
return getCraftedTextFromText(archive.getTextIfEmpty(fileName, text), repository, fileName)
|
||||
|
||||
def getCraftedTextFromText(gcodeText, repository=None):
|
||||
def getCraftedTextFromText(gcodeText, repository=None, fileName=''):
|
||||
'Alteration a gcode linear move text.'
|
||||
if gcodec.isProcedureDoneOrFileIsEmpty(gcodeText, 'alteration'):
|
||||
return gcodeText
|
||||
|
@ -103,7 +103,7 @@ def getCraftedTextFromText(gcodeText, repository=None):
|
|||
repository = settings.getReadRepository(AlterationRepository())
|
||||
if not repository.activateAlteration.value:
|
||||
return gcodeText
|
||||
return AlterationSkein().getCraftedGcode(gcodeText, repository)
|
||||
return AlterationSkein().getCraftedGcode(gcodeText, repository, fileName)
|
||||
|
||||
def getGcodeTextWithoutRedundantMcode(gcodeText):
|
||||
'Get gcode text without redundant M104 and M108.'
|
||||
|
@ -170,11 +170,12 @@ class AlterationSkein:
|
|||
|
||||
def addFromUpperLowerFile(self, fileName):
|
||||
"Add lines of text from the fileName or the lowercase fileName, if there is no file by the original fileName in the directory."
|
||||
alterationFileLines = settings.getAlterationFileLines(fileName)
|
||||
alterationFileLines = map(lambda l: l.replace('?filename?', self.fileName), settings.getAlterationFileLines(fileName))
|
||||
self.distanceFeedRate.addLinesSetAbsoluteDistanceMode(alterationFileLines)
|
||||
|
||||
def getCraftedGcode(self, gcodeText, repository):
|
||||
def getCraftedGcode(self, gcodeText, repository, fileName):
|
||||
"Parse gcode text and store the bevel gcode."
|
||||
self.fileName = fileName
|
||||
self.lines = archive.getTextLines(gcodeText)
|
||||
if repository.replaceVariableWithSetting.value:
|
||||
self.setSettingDictionary()
|
||||
|
|
|
@ -81,7 +81,7 @@ profileDefaultSettings = {
|
|||
}
|
||||
alterationDefault = {
|
||||
#######################################################################################
|
||||
'start.gcode': """;Sliced at: {day} {date} {time}
|
||||
'start.gcode': """;Sliced {filename} at: {day} {date} {time}
|
||||
;Basic settings: Layer height: {layer_height} Walls: {wall_thickness} Fill: {fill_density}
|
||||
;Print time: {print_time}
|
||||
;Filament used: {filament_amount}m {filament_weight}g
|
||||
|
@ -388,7 +388,7 @@ def calculateSolidLayerCount():
|
|||
## Alteration file functions
|
||||
#########################################################
|
||||
def replaceTagMatch(m):
|
||||
tag = m.group(0)[1:-1]
|
||||
tag = m.group(1)
|
||||
if tag == 'time':
|
||||
return time.strftime('%H:%M:%S')
|
||||
if tag == 'date':
|
||||
|
@ -410,7 +410,7 @@ def replaceTagMatch(m):
|
|||
elif isPreference(tag):
|
||||
f = getProfileSettingFloat(tag)
|
||||
else:
|
||||
return tag
|
||||
return '?%s?' % (tag)
|
||||
if (f % 1) == 0:
|
||||
return str(int(f))
|
||||
return str(f)
|
||||
|
@ -478,5 +478,5 @@ def getAlterationFileContents(filename):
|
|||
#Always remove the extruder on/off M codes. These are no longer needed in 5D printing.
|
||||
prefix = 'M101\nM103\n'
|
||||
|
||||
return unicode(prefix + re.sub("\{[^\}]*\}", replaceTagMatch, alterationContents).rstrip() + '\n' + postfix).encode('utf-8')
|
||||
return unicode(prefix + re.sub("\{([^\}]*)\}", replaceTagMatch, alterationContents).rstrip() + '\n' + postfix).encode('utf-8')
|
||||
|
||||
|
|
Loading…
Reference in New Issue