def getHopLine( self, line ): "Get hopped gcode line." splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line ) self.feedRateMinute = gcodec.getFeedRateMinute( self.feedRateMinute, splitLine ) if self.extruderActive: return line location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ) highestZ = location.z if self.oldLocation != None: highestZ = max( highestZ, self.oldLocation.z ) highestZHop = highestZ + self.hopHeight locationComplex = location.dropAxis( 2 ) if self.justDeactivated: oldLocationComplex = self.oldLocation.dropAxis( 2 ) distance = abs( locationComplex - oldLocationComplex ) if distance < self.minimumDistance: if self.isNextTravel(): return self.distanceFeedRate.getLineWithZ( line, splitLine, highestZHop ) alongRatio = min( 0.41666666, self.hopDistance / distance ) oneMinusAlong = 1.0 - alongRatio closeLocation = oldLocationComplex * oneMinusAlong + locationComplex * alongRatio self.distanceFeedRate.addLine( self.distanceFeedRate.getLineWithZ( line, splitLine, highestZHop ) ) if self.isNextTravel(): return self.distanceFeedRate.getLineWithZ( line, splitLine, highestZHop ) farLocation = oldLocationComplex * alongRatio + locationComplex * oneMinusAlong self.distanceFeedRate.addGcodeMovementZWithFeedRate( self.feedRateMinute, farLocation, highestZHop ) return line if self.isNextTravel(): return self.distanceFeedRate.getLineWithZ( line, splitLine, highestZHop ) return line
def addExtrusionIntro( self, line ): "Adds the additional linear gcode movement for the extrusion intro." splitG1Line = self.firstLinearGcodeMovement.split() firstMovementLocation = gcodec.getLocationFromSplitLine(None, splitG1Line) firstMovementFeedrate = gcodec.getFeedRateMinute(self.feedRateMinute/self.repository.firstPerimeterFeedrateOverFeedrate.value, splitG1Line) introX = abs( self.repository.absMaxXIntro.value ) introY = abs( self.repository.absMaxYIntro.value ) xAxisFirst=False if abs( firstMovementLocation.x ) < abs( firstMovementLocation.y ): xAxisFirst=True if (xAxisFirst and firstMovementLocation.x > 0) or (not xAxisFirst and firstMovementLocation.x < 0): introX = -introX; if (xAxisFirst and firstMovementLocation.y < 0) or (not xAxisFirst and firstMovementLocation.y > 0): introY = -introY; introLine = self.deriveIntroLine(self.firstLinearGcodeMovement, splitG1Line, introX, introY, firstMovementFeedrate) self.distanceFeedRate.addLine(introLine) self.distanceFeedRate.addLine( line ) if xAxisFirst: introLine = self.deriveIntroLine(self.firstLinearGcodeMovement, splitG1Line, firstMovementLocation.x, introY, self.feedRateMinute) else: introLine = self.deriveIntroLine(self.firstLinearGcodeMovement, splitG1Line, introX, firstMovementLocation.y, self.feedRateMinute) self.distanceFeedRate.addLine(introLine) introLine = self.getRaftlessSpeededLine(self.firstLinearGcodeMovement, splitG1Line) self.distanceFeedRate.addLine(introLine) self.wantsExtrusionIntro = False
def getAnimationLineDelay(self, coloredLine): "Get the animation line delay in milliseconds." # maybe later, add animation along line # nextLayerIndex = self.repository.layer.value # nextLineIndex = self.repository.line.value + 1 # coloredLinesLength = len( self.getColoredLines() ) # self.skein.feedRateMinute # if nextLineIndex >= coloredLinesLength: # if nextLayerIndex + 1 < len( self.skeinPanes ): # nextLayerIndex += 1 # nextLineIndex = 0 # else: # nextLineIndex = self.repository.line.value splitLine = gcodec.getSplitLineBeforeBracketSemicolon( coloredLine.displayString) self.skein.feedRateMinute = gcodec.getFeedRateMinute( self.skein.feedRateMinute, splitLine) feedRateSecond = self.skein.feedRateMinute / 60.0 coloredLineLength = abs( coloredLine.end - coloredLine.begin) / self.repository.scale.value duration = coloredLineLength / feedRateSecond animationLineDelay = int( round(1000.0 * duration / self.repository.animationLineQuickening.value)) return max(animationLineDelay, 1)
def getUnpausedArcMovement( self, line, splitLine ): "Get an unpaused arc movement." if self.oldLocation == None: return line self.feedRateMinute = gcodec.getFeedRateMinute( self.feedRateMinute, splitLine ) relativeLocation = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ) location = self.oldLocation + relativeLocation self.oldLocation = location halfPlaneLineDistance = 0.5 * abs( relativeLocation.dropAxis( 2 ) ) radius = gcodec.getDoubleFromCharacterSplitLine( 'R', splitLine ) if radius == None: relativeCenter = complex( gcodec.getDoubleFromCharacterSplitLine( 'I', splitLine ), gcodec.getDoubleFromCharacterSplitLine( 'J', splitLine ) ) radius = abs( relativeCenter ) angle = 0.0 if radius > 0.0: angle = math.pi if halfPlaneLineDistance < radius: angle = 2.0 * math.asin( halfPlaneLineDistance / radius ) else: angle *= halfPlaneLineDistance / radius deltaZ = abs( relativeLocation.z ) arcDistanceZ = complex( abs( angle ) * radius, relativeLocation.z ) distance = abs( arcDistanceZ ) if distance <= 0.0: return '' feedRateMinute = self.distanceFeedRate.getZLimitedFeedRate( deltaZ, distance, self.feedRateMinute ) indexOfF = gcodec.indexOfStartingWithSecond( "F", splitLine ) if indexOfF > 0 and feedRateMinute != self.feedRateMinute: feedRateStringOriginal = splitLine[ indexOfF ] feedRateStringReplacement = 'F' + self.distanceFeedRate.getRounded( feedRateMinute ) return line.replace( feedRateStringOriginal, feedRateStringReplacement ) return line
def getUnpausedArcMovement(self, line, splitLine): "Get an unpaused arc movement." if self.oldLocation == None: return line self.feedRateMinute = gcodec.getFeedRateMinute(self.feedRateMinute, splitLine) relativeLocation = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine) location = self.oldLocation + relativeLocation self.oldLocation = location halfPlaneLineDistance = 0.5 * abs(relativeLocation.dropAxis(2)) radius = gcodec.getDoubleFromCharacterSplitLine('R', splitLine) if radius == None: relativeCenter = complex( gcodec.getDoubleFromCharacterSplitLine('I', splitLine), gcodec.getDoubleFromCharacterSplitLine('J', splitLine)) radius = abs(relativeCenter) angle = 0.0 if radius > 0.0: angle = math.pi if halfPlaneLineDistance < radius: angle = 2.0 * math.asin(halfPlaneLineDistance / radius) else: angle *= halfPlaneLineDistance / radius deltaZ = abs(relativeLocation.z) arcDistanceZ = complex(abs(angle) * radius, relativeLocation.z) distance = abs(arcDistanceZ) if distance <= 0.0: return '' unpausedFeedRateMinute = self.distanceFeedRate.getZLimitedFeedRate( deltaZ, distance, self.feedRateMinute) return self.distanceFeedRate.getLineWithFeedRate( unpausedFeedRateMinute, line, splitLine)
def getUnpausedArcMovement( self, line, splitLine ): "Get an unpaused arc movement." if self.oldLocation == None: return line self.feedRateMinute = gcodec.getFeedRateMinute( self.feedRateMinute, splitLine ) relativeLocation = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ) location = self.oldLocation + relativeLocation self.oldLocation = location halfPlaneLineDistance = 0.5 * abs( relativeLocation.dropAxis( 2 ) ) radius = gcodec.getDoubleFromCharacterSplitLine( 'R', splitLine ) if radius == None: relativeCenter = complex( gcodec.getDoubleFromCharacterSplitLine( 'I', splitLine ), gcodec.getDoubleFromCharacterSplitLine( 'J', splitLine ) ) radius = abs( relativeCenter ) angle = 0.0 if radius > 0.0: angle = math.pi if halfPlaneLineDistance < radius: angle = 2.0 * math.asin( halfPlaneLineDistance / radius ) else: angle *= halfPlaneLineDistance / radius deltaZ = abs( relativeLocation.z ) arcDistanceZ = complex( abs( angle ) * radius, relativeLocation.z ) distance = abs( arcDistanceZ ) if distance <= 0.0: return '' unpausedFeedRateMinute = self.distanceFeedRate.getZLimitedFeedRate( deltaZ, distance, self.feedRateMinute ) return self.distanceFeedRate.getLineWithFeedRate( unpausedFeedRateMinute, line, splitLine )
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 linearMove( self, splitLine ): "Add line to time spent on layer." self.feedRateMinute = gcodec.getFeedRateMinute( self.feedRateMinute, splitLine ) location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ) if self.oldLocation != None: feedRateSecond = self.feedRateMinute / 60.0 self.layerTime += location.distance( self.oldLocation ) / feedRateSecond self.highestZ = max( location.z, self.highestZ ) self.oldLocation = location
def linearMove( self, splitLine ): "Bevel a linear move." location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ) self.feedRateMinute = gcodec.getFeedRateMinute( self.feedRateMinute, splitLine ) if self.oldLocation != None: nextLocation = self.getNextLocation() if nextLocation != None: location = self.splitPointGetAfter( location, nextLocation ) self.oldLocation = location self.oldFeedRateMinute = self.feedRateMinute
def linearMove( self, splitLine ): "Add to loop path if this is a loop or path." location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ) self.feedRateMinute = gcodec.getFeedRateMinute( self.feedRateMinute, splitLine ) if self.isLoopPerimeter: if self.isNextExtruderOn(): self.loopPath = euclidean.PathZ( location.z ) if self.loopPath != None: self.loopPath.path.append( location.dropAxis( 2 ) ) self.oldLocation = location
def getStretchedLine( self, splitLine ): "Get stretched gcode line." location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ) self.feedRateMinute = gcodec.getFeedRateMinute( self.feedRateMinute, splitLine ) self.oldLocation = location if self.extruderActive and self.threadMaximumAbsoluteStretch > 0.0: return self.getStretchedLineFromIndexLocation( self.lineIndex - 1, self.lineIndex + 1, location ) if self.isJustBeforeExtrusion() and self.threadMaximumAbsoluteStretch > 0.0: return self.getStretchedLineFromIndexLocation( self.lineIndex - 1, self.lineIndex + 1, location ) return self.lines[ self.lineIndex ]
def linearMove(self, splitLine): "Bevel a linear move." location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) self.feedRateMinute = gcodec.getFeedRateMinute(self.feedRateMinute, splitLine) if self.oldLocation != None: nextLocation = self.getNextLocation() if nextLocation != None: location = self.splitPointGetAfter(location, nextLocation) self.oldLocation = location self.oldFeedRateMinute = self.feedRateMinute
def getExtrusionDistanceString( self, distance, splitLine ): "Get the extrusion distance string." self.feedRateMinute = gcodec.getFeedRateMinute( self.feedRateMinute, splitLine ) if not self.isExtruderActive: return '' if distance <= 0.0: return '' extrusionDistance = self.feedOverFlow * self.flowRate / self.feedRateMinute * distance if self.repository.relativeExtrusionDistance.value: return ' E' + self.distanceFeedRate.getRounded( extrusionDistance ) self.totalExtrusionDistance += extrusionDistance return ' E' + self.distanceFeedRate.getRounded( self.totalExtrusionDistance )
def getUnpausedFeedRateMinute( self, location, splitLine ): "Get the feed rate which will compensate for the pause." self.feedRateMinute = gcodec.getFeedRateMinute( self.feedRateMinute, splitLine ) if self.oldLocation == None: return self.feedRateMinute distance = location.distance( self.oldLocation ) if distance <= 0.0: return self.feedRateMinute specifiedFeedRateSecond = self.feedRateMinute / 60.0 resultantReciprocal = 1.0 - self.delaySecond / distance * specifiedFeedRateSecond if resultantReciprocal < self.minimumSpeedUpReciprocal: return self.feedRateMinute * self.maximumSpeed return self.feedRateMinute / resultantReciprocal
def linearMove( self, splitLine ): "Add to loop path if this is a loop or path." location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ) self.feedRateMinute = gcodec.getFeedRateMinute( self.feedRateMinute, splitLine ) if self.isLoopPerimeter: if self.isNextExtruderOn(): self.loopPath = euclidean.PathZ( location.z ) if self.loopPath == None: if self.extruderActive: self.oldWiddershins = None else: self.loopPath.path.append( location.dropAxis( 2 ) ) self.oldLocation = location
def getStretchedLine(self, splitLine): "Get stretched gcode line." location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) self.feedRateMinute = gcodec.getFeedRateMinute(self.feedRateMinute, splitLine) self.oldLocation = location if self.extruderActive and self.threadMaximumAbsoluteStretch > 0.0: return self.getStretchedLineFromIndexLocation( self.lineIndex - 1, self.lineIndex + 1, location) if self.isJustBeforeExtrusion( ) and self.threadMaximumAbsoluteStretch > 0.0: return self.getStretchedLineFromIndexLocation( self.lineIndex - 1, self.lineIndex + 1, location) return self.lines[self.lineIndex]
def getActiveFeedRateRatio( self ): "Get the feed rate of the first active move over the operating feed rate." isSearchExtruderActive = self.isExtruderActive for afterIndex in xrange( self.lineIndex, len( self.lines ) ): line = self.lines[ afterIndex ] splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line ) firstWord = gcodec.getFirstWord( splitLine ) if firstWord == 'G1': if isSearchExtruderActive: return gcodec.getFeedRateMinute( self.feedRateMinute, splitLine ) / self.operatingFeedRateMinute elif firstWord == 'M101': isSearchExtruderActive = True print( 'active feed rate ratio was not found in oozebane.' ) return 1.0
def getUnpausedFeedRateMinute(self, location, splitLine): "Get the feed rate which will compensate for the pause." self.feedRateMinute = gcodec.getFeedRateMinute(self.feedRateMinute, splitLine) if self.oldLocation == None: return self.feedRateMinute distance = location.distance(self.oldLocation) if distance <= 0.0: return self.feedRateMinute specifiedFeedRateSecond = self.feedRateMinute / 60.0 resultantReciprocal = 1.0 - self.delaySecond / distance * specifiedFeedRateSecond if resultantReciprocal < self.minimumSpeedUpReciprocal: return self.feedRateMinute * self.maximumSpeed return self.feedRateMinute / resultantReciprocal
def getLinearMove( self, line, splitLine ): "Add to loop path if this is a loop or path." location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ) self.feedRateMinute = gcodec.getFeedRateMinute( self.feedRateMinute, splitLine ) if self.isLoopPerimeter: if self.isNextExtruderOn(): self.loopPath = euclidean.PathZ( location.z ) if self.oldLocation != None: self.beforeLoopLocation = self.oldLocation.dropAxis( 2 ) self.oldLocation = location if self.loopPath == None: self.oldLoopLocationComplex = None return line self.loopPath.path.append( location.dropAxis( 2 ) ) return ''
def getOozebaneLine( self, line ): "Get oozebaned gcode line." splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line ) self.feedRateMinute = gcodec.getFeedRateMinute( self.feedRateMinute, splitLine ) if self.oldLocation == None: return line if self.startupStepIndex < len( self.afterStartupDistances ): return self.getAddAfterStartupLines( line ) if self.extruderInactiveLongEnough: return self.getAddBeforeStartupLines( line ) if self.shutdownStepIndex < len( self.earlyShutdownDistances ): return self.getAddShutSlowDownLines( line ) if self.isStartupEarly: return self.getLinearMoveWithFeedRateSplitLine( self.operatingFeedRateMinute, splitLine ) return line
def getLinearMove(self, line, splitLine): "Add to loop path if this is a loop or path." location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) self.feedRateMinute = gcodec.getFeedRateMinute(self.feedRateMinute, splitLine) if self.isLoopPerimeter: if self.isNextExtruderOn(): self.loopPath = euclidean.PathZ(location.z) if self.oldLocation != None: self.beforeLoopLocation = self.oldLocation.dropAxis(2) self.oldLocation = location if self.loopPath == None: self.oldLoopLocationComplex = None return line self.loopPath.path.append(location.dropAxis(2)) return ""
def getRaftedLine( self, splitLine ): "Get elevated gcode line with operating feed rate." location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ) self.feedRateMinute = gcodec.getFeedRateMinute( self.feedRateMinute, splitLine ) self.oldLocation = location z = location.z if self.operatingJump != None: z += self.operatingJump if not self.isFirstLayerWithinTemperatureAdded and not self.isSurroundingLoop: self.isFirstLayerWithinTemperatureAdded = True self.addTemperature( self.raftRepository.temperatureShapeFirstLayerWithin.value ) if self.raftRepository.addRaftElevateNozzleOrbitSetAltitude.value: boundaryLoops = self.boundaryLayers[ self.layerIndex ].loops if len( boundaryLoops ) > 1: self.addOperatingOrbits( boundaryLoops, euclidean.getXYComplexFromVector3( self.oldLocation ), self.raftRepository.temperatureChangeTimeBeforeNextThreads.value, z ) return self.distanceFeedRate.getLinearGcodeMovementWithFeedRate( self.feedRateMinute, location.dropAxis( 2 ), z )
def getLayerTime( self ): "Get the time the extruder spends on the layer." feedRateMinute = self.feedRateMinute layerTime = 0.0 lastThreadLocation = self.oldLocation for lineIndex in xrange( self.lineIndex, len( self.lines ) ): line = self.lines[ lineIndex ] splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line ) firstWord = gcodec.getFirstWord( splitLine ) if firstWord == 'G1': location = gcodec.getLocationFromSplitLine( lastThreadLocation, splitLine ) feedRateMinute = gcodec.getFeedRateMinute( feedRateMinute, splitLine ) if lastThreadLocation != None: feedRateSecond = feedRateMinute / 60.0 layerTime += location.distance( lastThreadLocation ) / feedRateSecond lastThreadLocation = location elif firstWord == '(</layer>)': return layerTime return layerTime
def getAnimationLineDelay( self, coloredLine ): "Get the animation line delay in milliseconds." # maybe later, add animation along line # nextLayerIndex = self.repository.layer.value # nextLineIndex = self.repository.line.value + 1 # coloredLinesLength = len( self.getColoredLines() ) # self.skein.feedRateMinute # if nextLineIndex >= coloredLinesLength: # if nextLayerIndex + 1 < len( self.skeinPanes ): # nextLayerIndex += 1 # nextLineIndex = 0 # else: # nextLineIndex = self.repository.line.value splitLine = gcodec.getSplitLineBeforeBracketSemicolon( coloredLine.displayString ) self.skein.feedRateMinute = gcodec.getFeedRateMinute( self.skein.feedRateMinute, splitLine ) feedRateSecond = self.skein.feedRateMinute / 60.0 coloredLineLength = abs( coloredLine.end - coloredLine.begin ) / self.repository.scale.value duration = coloredLineLength / feedRateSecond animationLineDelay = int( round( 1000.0 * duration / self.repository.animationLineQuickening.value ) ) return max( animationLineDelay, 1 )
def getSplodgeLine( self, line, location, splitLine ): "Add splodged gcode line." self.feedRateMinute = gcodec.getFeedRateMinute( self.feedRateMinute, splitLine ) if not self.hasInitialSplodgeBeenAdded: return self.getInitialSplodgeLine( line, location ) return self.getOperatingSplodgeLine( line, location )
def getCoolMove( self, line, location, splitLine ): "Add line to time spent on layer." self.feedRateMinute = gcodec.getFeedRateMinute( self.feedRateMinute, splitLine ) self.highestZ = max( location.z, self.highestZ ) self.addFlowRateLineIfNecessary( self.multiplier * self.oldFlowRate ) return self.distanceFeedRate.getLineWithZLimitedFeedRate( self.multiplier * self.feedRateMinute, line, location, splitLine )