def getRelativeStretch( self, location, lineIndexRange ): "Get relative stretch for a location minus a point." locationComplex = location.dropAxis( 2 ) lastLocationComplex = locationComplex oldTotalLength = 0.0 pointComplex = locationComplex stretchRatio = 1.0 totalLength = 0.0 if not self.extruderActive: stretchRatio = self.stretchPreferences.travelOverExtrusionStretch.value for lineIndex in lineIndexRange: line = self.lines[ lineIndex ] splitLine = line.split( ' ' ) firstWord = '' if len( splitLine ) > 0: firstWord = splitLine[ 0 ] if firstWord == 'G1': pointComplex = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ).dropAxis( 2 ) locationMinusPoint = lastLocationComplex - pointComplex locationMinusPointLength = abs( locationMinusPoint ) totalLength += locationMinusPointLength if totalLength >= self.stretchFromDistance: distanceFromRatio = ( self.stretchFromDistance - oldTotalLength ) / locationMinusPointLength totalPoint = distanceFromRatio * pointComplex + ( 1.0 - distanceFromRatio ) * lastLocationComplex locationMinusTotalPoint = locationComplex - totalPoint return stretchRatio * locationMinusTotalPoint / self.stretchFromDistance lastLocationComplex = pointComplex oldTotalLength = totalLength elif firstWord == 'M103': stretchRatio = self.stretchPreferences.travelOverExtrusionStretch.value locationMinusPoint = locationComplex - pointComplex locationMinusPointLength = abs( locationMinusPoint ) if locationMinusPointLength > 0.0: return stretchRatio * locationMinusPoint / locationMinusPointLength return complex()
def addIfTravel(self, splitLine): "Add travel move around loops if this the extruder is off." location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) if not self.extruderActive and self.oldLocation != None: self.insertPathsBetween(self.getOutloopLocation(location), self.getOutloopLocation(self.oldLocation)) self.oldLocation = location
def linearCorner( self, splitLine ): "Update the bounding corners." location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ) if self.extruderActive: self.cornerHigh = euclidean.getPointMaximum( self.cornerHigh, location ) self.cornerLow = euclidean.getPointMinimum( self.cornerLow, location ) self.oldLocation = location
def getLocationSetFeedrateToSplitLine(self, splitLine): location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) indexOfF = gcodec.indexOfStartingWithSecond("F", splitLine) if indexOfF > 0: self.feedrateMinute = gcodec.getDoubleAfterFirstLetter( splitLine[indexOfF]) return location
def setHelicalMoveEndpoint( self, splitLine ): "Get the endpoint of a helical move." if self.oldLocation == None: print >> sys.stderr, ( "A helical move must not be the first move of a gcode file." ) return location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ) location.add( self.oldLocation ) self.oldLocation = location
def linearMove( self, splitLine ): "Add a linear move to the loop." location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ) self.feedrateMinute = gcodec.getFeedrateMinute( self.feedrateMinute, splitLine ) self.feedrateTable[ location ] = self.feedrateMinute if self.extruderActive: self.addToExtrusion( location ) self.oldLocation = location
def getStretchedLine( self, splitLine ): "Get stretched gcode line." location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ) self.feedrateMinute = gcodec.getFeedrateMinute( self.feedrateMinute, splitLine ) if self.oldLocation != None: self.addStretchesBeforePoint( location ) self.oldLocation = location return self.getStretchedLineFromIndexLocation( self.lineIndex - 1, self.lineIndex + 1, location )
def setHelicalMoveEndpoint(self, splitLine): "Get the endpoint of a helical move." if self.oldLocation == None: print >> sys.stderr, ( "A helical move must not be the first move of a gcode file.") return location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) location.add(self.oldLocation) self.oldLocation = location
def linearMove(self, splitLine): "Add a linear move to the loop." location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) self.feedrateMinute = gcodec.getFeedrateMinute(self.feedrateMinute, splitLine) self.feedrateTable[location] = self.feedrateMinute if self.extruderActive: self.addToExtrusion(location) self.oldLocation = location
def getStretchedLine(self, splitLine): "Get stretched gcode line." location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) self.feedrateMinute = gcodec.getFeedrateMinute(self.feedrateMinute, splitLine) if self.oldLocation != None: self.addStretchesBeforePoint(location) self.oldLocation = location return self.getStretchedLineFromIndexLocation(self.lineIndex - 1, self.lineIndex + 1, location)
def linearMove( self, splitLine ): "Bevel a linear move." location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ) self.feedrateMinute = gcodec.getFeedrateMinute( self.feedrateMinute, splitLine ) if not self.extruderActive: return if self.oldActiveLocation != None: nextActive = self.getNextActive() if nextActive != None: self.shouldAddLine = False location = self.splitPointGetAfter( location, nextActive, self.oldActiveLocation ) self.oldActiveLocation = location
def linearMove(self, splitLine): "Bevel a linear move." location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) self.feedrateMinute = gcodec.getFeedrateMinute(self.feedrateMinute, splitLine) if not self.extruderActive: return if self.oldActiveLocation != None: nextActive = self.getNextActive() if nextActive != None: self.shouldAddLine = False location = self.splitPointGetAfter(location, nextActive, self.oldActiveLocation) self.oldActiveLocation = location
def getNextActive( self ): "Get the next linear move where the extruder is still active. Return none is none is found." for afterIndex in range( self.lineIndex + 1, len( self.lines ) ): line = self.lines[ afterIndex ] splitLine = line.split( ' ' ) firstWord = ""; if len( splitLine ) > 0: firstWord = splitLine[ 0 ] if firstWord == 'G1': nextActive = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ) return nextActive if firstWord == 'M103': return None return None
def getNextActive(self): "Get the next linear move where the extruder is still active. Return none is none is found." for afterIndex in range(self.lineIndex + 1, len(self.lines)): line = self.lines[afterIndex] splitLine = line.split(' ') firstWord = "" if len(splitLine) > 0: firstWord = splitLine[0] if firstWord == 'G1': nextActive = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine) return nextActive if firstWord == 'M103': return None return None
def getRelativeStretch(self, location, lineIndexRange): "Get relative stretch for a location minus a point." locationComplex = location.dropAxis(2) lastLocationComplex = locationComplex oldTotalLength = 0.0 pointComplex = locationComplex stretchRatio = 1.0 totalLength = 0.0 if not self.extruderActive: stretchRatio = self.stretchPreferences.travelOverExtrusionStretch.value for lineIndex in lineIndexRange: line = self.lines[lineIndex] splitLine = line.split(' ') firstWord = '' if len(splitLine) > 0: firstWord = splitLine[0] if firstWord == 'G1': pointComplex = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine).dropAxis(2) locationMinusPoint = lastLocationComplex - pointComplex locationMinusPointLength = abs(locationMinusPoint) totalLength += locationMinusPointLength if totalLength >= self.stretchFromDistance: distanceFromRatio = ( self.stretchFromDistance - oldTotalLength) / locationMinusPointLength totalPoint = distanceFromRatio * pointComplex + ( 1.0 - distanceFromRatio) * lastLocationComplex locationMinusTotalPoint = locationComplex - totalPoint return stretchRatio * locationMinusTotalPoint / self.stretchFromDistance lastLocationComplex = pointComplex oldTotalLength = totalLength elif firstWord == 'M103': stretchRatio = self.stretchPreferences.travelOverExtrusionStretch.value locationMinusPoint = locationComplex - pointComplex locationMinusPointLength = abs(locationMinusPoint) if locationMinusPointLength > 0.0: return stretchRatio * locationMinusPoint / locationMinusPointLength return complex()
def linearMove( self, splitLine ): "Add a linear move to the loop." location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ) if self.extruderActive: self.addToLoop( location ) self.oldLocation = location
def addIfTravel( self, splitLine ): "Add travel move around loops if this the extruder is off." location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ) if not self.extruderActive and self.oldLocation != None: self.insertPathsBetween( self.getOutloopLocation( location ), self.getOutloopLocation( self.oldLocation ) ) self.oldLocation = location
def addIfTravel( self, splitLine ): "Add travel move around loops if this the extruder is off." location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ) self.oldLocation = location
def linearMove( self, splitLine, nextLine ): "Get statistics for a linear move." location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ) self.addToPath( location, nextLine ) self.oldLocation = location
def addIfTravel(self, splitLine): "Add travel move around loops if this the extruder is off." location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) self.oldLocation = location
def getLocationSetFeedrateToSplitLine( self, splitLine ): location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ) indexOfF = gcodec.indexOfStartingWithSecond( "F", splitLine ) if indexOfF > 0: self.feedrateMinute = gcodec.getDoubleAfterFirstLetter( splitLine[ indexOfF ] ) return location
def linearMove( self, splitLine ): "Comment a linear move." location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ) self.addComment( "Linear move to " + str( location ) + "." ); self.oldLocation = location
def linearMove(self, splitLine): "Add a linear move to the loop." location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) if self.extruderActive: self.addToLoop(location) self.oldLocation = location
def linearMove(self, splitLine): "Comment a linear move." location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) self.addComment("Linear move to " + str(location) + ".") self.oldLocation = location