def getCraftedGcode( self, gcodeText, coolRepository ): "Parse gcode text and store the cool gcode." self.coolRepository = coolRepository self.coolEndText = settings.getFileInAlterationsOrGivenDirectory( os.path.dirname( __file__ ), 'Cool_End.gcode' ) self.coolEndLines = gcodec.getTextLines( self.coolEndText ) self.coolStartText = settings.getFileInAlterationsOrGivenDirectory( os.path.dirname( __file__ ), 'Cool_Start.gcode' ) self.coolStartLines = gcodec.getTextLines( self.coolStartText ) self.halfCorner = complex( coolRepository.minimumOrbitalRadius.value, coolRepository.minimumOrbitalRadius.value ) self.lines = gcodec.getTextLines( gcodeText ) self.minimumArea = 4.0 * coolRepository.minimumOrbitalRadius.value * coolRepository.minimumOrbitalRadius.value self.parseInitialization() self.boundingRectangle = gcodec.BoundingRectangle().getFromGcodeLines( self.lines[ self.lineIndex : ], 0.5 * self.perimeterWidth ) margin = 0.2 * self.perimeterWidth halfCornerMargin = self.halfCorner + complex( margin, margin ) self.boundingRectangle.cornerMaximum -= halfCornerMargin self.boundingRectangle.cornerMinimum += halfCornerMargin for self.lineIndex in xrange( self.lineIndex, len( self.lines ) ): line = self.lines[ self.lineIndex ] self.parseLine( line ) if coolRepository.turnFanOffAtEnding.value: self.distanceFeedRate.addLine( 'M107' ) return self.distanceFeedRate.output.getvalue()
def getReplaced( exportText ): "Get text with words replaced according to replace.csv file." replaceText = settings.getFileInAlterationsOrGivenDirectory( os.path.dirname( __file__ ), 'Replace.csv' ) if replaceText == '': return exportText lines = gcodec.getTextLines( replaceText ) for line in lines: replacedLine = line.replace( ',', ' ' ) replacedLine = replacedLine.replace( '\t', ' ' ) splitLine = replacedLine.split() if len( splitLine ) > 1: exportText = exportText.replace( splitLine[ 0 ], splitLine[ 1 ] ) return exportText
def getCraftedGcode(self, gcodeText, homeRepository): "Parse gcode text and store the home gcode." self.homingText = settings.getFileInAlterationsOrGivenDirectory( os.path.dirname(__file__), homeRepository.nameOfHomingFile.value) if len(self.homingText) < 1: return gcodeText self.lines = gcodec.getTextLines(gcodeText) self.homeRepository = homeRepository self.parseInitialization(homeRepository) self.homingLines = gcodec.getTextLines(self.homingText) for self.lineIndex in xrange(self.lineIndex, len(self.lines)): line = self.lines[self.lineIndex] self.parseLine(line) return self.distanceFeedRate.output.getvalue()
def getReplaced(exportText): "Get text with words replaced according to replace.csv file." replaceText = settings.getFileInAlterationsOrGivenDirectory( os.path.dirname(__file__), 'Replace.csv') if replaceText == '': return exportText lines = gcodec.getTextLines(replaceText) for line in lines: replacedLine = line.replace(',', ' ') replacedLine = replacedLine.replace('\t', ' ') splitLine = replacedLine.split() if len(splitLine) > 1: exportText = exportText.replace(splitLine[0], splitLine[1]) return exportText
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." fileText = settings.getFileInAlterationsOrGivenDirectory( os.path.dirname( __file__ ), fileName ) fileLines = gcodec.getTextLines( fileText ) self.distanceFeedRate.addLinesSetAbsoluteDistanceMode( fileLines )
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." fileText = settings.getFileInAlterationsOrGivenDirectory( os.path.dirname(__file__), fileName) fileLines = gcodec.getTextLines(fileText) self.distanceFeedRate.addLinesSetAbsoluteDistanceMode(fileLines)