def getCraftedGcode(self, gcodeText, coolRepository): "Parse gcode text and store the cool gcode." self.coolRepository = coolRepository self.coolEndText = preferences.getFileInAlterationsOrGivenDirectory(os.path.dirname(__file__), "Cool_End.gcode") self.coolEndLines = gcodec.getTextLines(self.coolEndText) self.coolStartText = preferences.getFileInAlterationsOrGivenDirectory( os.path.dirname(__file__), "Cool_Start.gcode" ) self.coolStartLines = gcodec.getTextLines(self.coolStartText) self.cornerMaximum = complex(-999999999.0, -999999999.0) self.cornerMinimum = complex(999999999.0, 999999999.0) 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() for lineIndex in xrange(self.lineIndex, len(self.lines)): line = self.lines[lineIndex] self.parseCorner(line) margin = 0.2 * self.perimeterWidth halfCornerMargin = self.halfCorner + complex(margin, margin) self.cornerMaximum -= halfCornerMargin self.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 getCraftedGcode( self, gcodeText, raftRepository ): "Parse gcode text and store the raft gcode." self.raftRepository = raftRepository self.supportEndText = preferences.getFileInAlterationsOrGivenDirectory( os.path.dirname( __file__ ), 'Support_End.gcode' ) self.supportEndLines = gcodec.getTextLines( self.supportEndText ) self.supportStartText = preferences.getFileInAlterationsOrGivenDirectory( os.path.dirname( __file__ ), 'Support_Start.gcode' ) self.supportStartLines = gcodec.getTextLines( self.supportStartText ) self.minimumSupportRatio = math.tan( math.radians( raftRepository.supportMinimumAngle.value ) ) self.lines = gcodec.getTextLines( gcodeText ) self.parseInitialization() if raftRepository.addRaftElevateNozzleOrbitSetAltitude.value: self.addRaft() self.addTemperature( raftRepository.temperatureShapeFirstLayerOutline.value ) for line in self.lines[ self.lineIndex : ]: self.parseLine( line ) return self.distanceFeedRate.output.getvalue()
def getCraftedGcode( self, gcodeText, coolPreferences ): "Parse gcode text and store the cool gcode." self.coolPreferences = coolPreferences self.coolEndText = preferences.getFileInAlterationsOrGivenDirectory( os.path.dirname( __file__ ), 'Cool_End.gcode' ) self.coolEndLines = gcodec.getTextLines( self.coolEndText ) self.coolStartText = preferences.getFileInAlterationsOrGivenDirectory( os.path.dirname( __file__ ), 'Cool_Start.gcode' ) self.coolStartLines = gcodec.getTextLines( self.coolStartText ) self.halfCorner = complex( coolPreferences.minimumOrbitalRadius.value, coolPreferences.minimumOrbitalRadius.value ) self.lines = gcodec.getTextLines( gcodeText ) self.minimumArea = 4.0 * coolPreferences.minimumOrbitalRadius.value * coolPreferences.minimumOrbitalRadius.value self.parseInitialization() for self.lineIndex in xrange( self.lineIndex, len( self.lines ) ): line = self.lines[ self.lineIndex ] self.parseLine( line ) if coolPreferences.turnFanOffAtEnding.value: self.distanceFeedRate.addLine( 'M107' ) return self.distanceFeedRate.output.getvalue()
def getCraftedGcode( self, gcodeText, homePreferences ): "Parse gcode text and store the home gcode." self.lines = gcodec.getTextLines( gcodeText ) self.homePreferences = homePreferences self.parseInitialization( homePreferences ) self.homingText = preferences.getFileInAlterationsOrGivenDirectory( os.path.dirname( __file__ ), homePreferences.nameOfHomingFile.value ) 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 = preferences.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 = preferences.getFileInAlterationsOrGivenDirectory( os.path.dirname( __file__ ), fileName ) fileLines = gcodec.getTextLines( fileText ) self.distanceFeedRate.addLinesSetAbsoluteDistanceMode( fileLines )