def parseLine(self, line): 'Parse a gcode line.' splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) if len(splitLine) < 1: return firstWord = splitLine[0] if firstWord == '(</crafting>)': self.crafting = False elif firstWord == '(<decimalPlacesCarried>': self.decimalPlacesExported = int(splitLine[1]) - 1 if self.repository.deleteAllComments.value or (self.repository.deleteCraftingComments.value and self.crafting): if firstWord[0] == '(': return else: line = line.split(';')[0].split('(')[0].strip() if firstWord == '(<crafting>)': self.crafting = True if firstWord == '(</extruderInitialization>)': self.addLine(gcodec.getTagBracketedProcedure('export')) if firstWord != 'G1' and firstWord != 'G2' and firstWord != 'G3' : self.addLine(line) return line = self.getLineWithTruncatedNumber('X', line, splitLine) line = self.getLineWithTruncatedNumber('Y', line, splitLine) line = self.getLineWithTruncatedNumber('Z', line, splitLine) line = self.getLineWithTruncatedNumber('I', line, splitLine) line = self.getLineWithTruncatedNumber('J', line, splitLine) line = self.getLineWithTruncatedNumber('R', line, splitLine) self.addLine(line)
def parseLine(self, line): 'Parse a gcode line.' splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) if len(splitLine) < 1: self.addLine(line) return firstWord = splitLine[0] if firstWord == '(</crafting>)': self.crafting = False elif firstWord == '(<decimalPlacesCarried>': self.decimalPlacesExported = int(splitLine[1]) - 1 if self.repository.deleteAllComments.value or ( self.repository.deleteCraftingComments.value and self.crafting): if firstWord[0] == '(': return else: line = line.split(';')[0].split('(')[0].strip() if firstWord == '(<crafting>)': self.crafting = True if firstWord == '(</extruderInitialization>)': self.addLine(gcodec.getTagBracketedProcedure('export')) if firstWord != 'G1' and firstWord != 'G2' and firstWord != 'G3': self.addLine(line) return line = self.getLineWithTruncatedNumber('X', line, splitLine) line = self.getLineWithTruncatedNumber('Y', line, splitLine) line = self.getLineWithTruncatedNumber('Z', line, splitLine) line = self.getLineWithTruncatedNumber('I', line, splitLine) line = self.getLineWithTruncatedNumber('J', line, splitLine) line = self.getLineWithTruncatedNumber('R', line, splitLine) self.addLine(line)
def parseInitialization( self, splodgeRepository ): 'Parse gcode initialization and store the parameters.' for self.lineIndex in xrange(len(self.lines)): line = self.lines[self.lineIndex] splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) self.distanceFeedRate.parseSplitLine(firstWord, splitLine) if firstWord == '(</extruderInitialization>)': self.addLineUnlessIdenticalReactivate(gcodec.getTagBracketedProcedure('splodge')) return elif firstWord == '(<layerThickness>': self.layerThickness = float(splitLine[1]) elif firstWord == '(<operatingFeedRatePerSecond>': self.operatingFeedRatePerSecond = float(splitLine[1]) elif firstWord == '(<perimeterWidth>': self.perimeterWidth = float(splitLine[1]) self.minimumQuantityLength = 0.1 * self.perimeterWidth self.addLineUnlessIdenticalReactivate(line)
def parseInitialization( self, splodgeRepository ): 'Parse gcode initialization and store the parameters.' for self.lineIndex in xrange(len(self.lines)): line = self.lines[self.lineIndex] splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) self.distanceFeedRate.parseSplitLine(firstWord, splitLine) if firstWord == '(</extruderInitialization>)': self.addLineUnlessIdenticalReactivate(gcodec.getTagBracketedProcedure('splodge')) return elif firstWord == '(<layerHeight>': self.layerHeight = float(splitLine[1]) elif firstWord == '(<operatingFeedRatePerSecond>': self.operatingFeedRatePerSecond = float(splitLine[1]) elif firstWord == '(<edgeWidth>': self.edgeWidth = float(splitLine[1]) self.minimumQuantityLength = 0.1 * self.edgeWidth self.addLineUnlessIdenticalReactivate(line)
def parseLine(self, line): 'Parse a gcode line.' splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) if len(splitLine) < 1: return firstWord = splitLine[0] if firstWord == '(<alteration>)': self.inPreface = False if firstWord == '(<crafting>)': self.crafting = True if not self.repository.deleteCraftingComments.value: self.addLine(line) return if firstWord == '(</crafting>)': self.crafting = False if not self.repository.deleteCraftingComments.value: self.addLine(line) return if firstWord == '(<decimalPlacesCarried>': self.decimalPlacesExported = int(splitLine[1]) - 1 if firstWord == '(<keep>': if not self.repository.deleteKeepComments.value: self.addLine(line) return if firstWord == '(<layer>' or firstWord.find('(</layer>') == 0: if not self.repository.deleteLayerComments.value: self.addLine(line) return if firstWord == '(<trace>': if not self.repository.deleteTraceComments.value: self.addLine(line) return if firstWord == '(<settings>)' or firstWord == '(<setting>' or firstWord == '(</settings>)': if not self.repository.deleteSettingsComments.value: self.addLine(line) return if firstWord == '(<extruderInitialization>)': self.inInitialisation = True if not self.repository.deleteInitialisationComments.value: self.addLine(line) return if firstWord == '(</extruderInitialization>)': self.inInitialisation = False if not self.repository.deleteInitialisationComments.value: self.addLine(gcodec.getTagBracketedProcedure('export')) self.addLine(line) return if firstWord[0] == '(': if self.inPreface: if self.repository.deletePrefaceComments.value: return elif self.inInitialisation: if self.repository.deleteInitialisationComments.value: return elif firstWord[1] == '<': if self.crafting: if self.repository.deleteCraftingComments.value: return elif self.repository.deleteTaggedComments.value: return elif firstWord[1] == '*': if self.repository.deleteStarredComments.value: return elif self.repository.deleteOtherComments.value: return if firstWord != 'G1' and firstWord != 'G2' and firstWord != 'G3' : self.addLine(line) return line = self.getLineWithTruncatedNumber('X', line, splitLine) line = self.getLineWithTruncatedNumber('Y', line, splitLine) line = self.getLineWithTruncatedNumber('Z', line, splitLine) line = self.getLineWithTruncatedNumber('I', line, splitLine) line = self.getLineWithTruncatedNumber('J', line, splitLine) line = self.getLineWithTruncatedNumber('R', line, splitLine) self.addLine(line)