def getFirstValue(gcodeText, word): 'Get the value from the first line which starts with the given word.' for line in archive.getTextLines(gcodeText): splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) if gcodec.getFirstWord(splitLine) == word: return splitLine[1] return ''
def parseInitialization(self): '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 == '(<layerHeight>': self.layerHeight = float(splitLine[1]) elif firstWord == '(</extruderInitialization>)': self.distanceFeedRate.addTagBracketedProcedure('speed') return elif firstWord == '(<edgeWidth>': self.absoluteEdgeWidth = abs(float(splitLine[1])) self.distanceFeedRate.addTagBracketedLine('maximumZTravelFeedRatePerSecond', self.repository.maximumZFeedRatePerSecond.value ) self.distanceFeedRate.addTagBracketedLine('objectFirstLayerFeedRateInfillMultiplier', self.repository.objectFirstLayerFeedRateInfillMultiplier.value) self.distanceFeedRate.addTagBracketedLine('operatingFeedRatePerSecond', self.feedRatePerSecond ) self.distanceFeedRate.addTagBracketedLine('edgeFeedRatePerSecond', self.repository.edgeFeedRateMultiplier.value )#todo comment? if self.repository.addFlowRate.value: self.distanceFeedRate.addTagBracketedLine('objectFirstLayerFlowRateInfillMultiplier', self.repository.objectFirstLayerFlowRateInfillMultiplier.value) self.distanceFeedRate.addTagBracketedLine('operatingFlowRate', self.repository.flowRateSetting.value ) orbitalFeedRatePerSecond = self.feedRatePerSecond * self.repository.orbitalFeedRateOverOperatingFeedRate.value self.distanceFeedRate.addTagBracketedLine('orbitalFeedRatePerSecond', orbitalFeedRatePerSecond ) self.distanceFeedRate.addTagBracketedLine('travelFeedRatePerSecond', self.repository.travelFeedRatePerSecond.value ) self.distanceFeedRate.addTagBracketedLine('FirstLayerTravelSpeed', self.repository.objectFirstLayerTravelSpeed.value ) elif firstWord == '(<nozzleDiameter>': self.nozzleDiameter = float(splitLine[1]) elif firstWord == '(<nozzleXsection>': self.nozzleXsection = float(splitLine[1]) self.distanceFeedRate.addLine(line)
def setSkirtFeedFlowTemperature(self): "Set the skirt feed rate, flow rate and temperature to that of the next extrusion." isExtruderActive = self.isExtruderActive isSupportLayer = self.isSupportLayer for lineIndex in xrange(self.lineIndex, len(self.lines)): line = self.lines[lineIndex] splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if firstWord == "G1": self.feedRateMinute = gcodec.getFeedRateMinute(self.feedRateMinute, splitLine) if isExtruderActive: if not isSupportLayer: return elif firstWord == "M101": isExtruderActive = True elif firstWord == "M103": isExtruderActive = False elif firstWord == "M104": self.skirtTemperature = gcodec.getDoubleAfterFirstLetter(splitLine[1]) elif firstWord == "M108": self.skirtFlowRate = gcodec.getDoubleAfterFirstLetter(splitLine[1]) elif firstWord == "(<supportLayer>)": isSupportLayer = True elif firstWord == "(</supportLayer>)": isSupportLayer = False
def getDistanceToThreadBeginningAfterThreadEnd( self, remainingDistance ): "Get the distance to the thread beginning after the end of this thread." extruderOnReached = False line = self.lines[self.lineIndex] splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) lastThreadLocation = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) threadEndReached = False totalDistance = 0.0 for afterIndex in xrange( self.lineIndex + 1, len(self.lines) ): line = self.lines[ afterIndex ] splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if firstWord == 'G1': location = gcodec.getLocationFromSplitLine( lastThreadLocation, splitLine ) if threadEndReached: totalDistance += location.distance( lastThreadLocation ) if totalDistance >= remainingDistance: return None if extruderOnReached: return totalDistance lastThreadLocation = location elif firstWord == 'M101': extruderOnReached = True elif firstWord == 'M103': threadEndReached = True return None
def getLayerTimeActive(self): 'Get the time the extruder spends on the layer while active.' feedRateMinute = self.feedRateMinute isExtruderActive = self.isExtruderActive 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 and isExtruderActive: feedRateSecond = feedRateMinute / 60.0 layerTime += location.distance(lastThreadLocation) / feedRateSecond lastThreadLocation = location elif firstWord == 'M101': isExtruderActive = True elif firstWord == 'M103': isExtruderActive = False elif firstWord == '(<bridgeRotation>': self.isBridgeLayer = True elif firstWord == '(</layer>)': return layerTime return layerTime
def parseInitialization(self): '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.distanceFeedRate.addTagBracketedProcedure('temperature') return elif firstWord == '(<edgeWidth>': self.distanceFeedRate.addTagBracketedLine('coolingRate', self.repository.coolingRate.value ) self.distanceFeedRate.addTagBracketedLine('heatingRate', self.repository.heatingRate.value ) self.distanceFeedRate.addTagBracketedLine('baseTemperature', self.repository.baseTemperature.value ) if self.repository.baseTempAlltemps.value: self.distanceFeedRate.addTagBracketedLine('interfaceTemperature', self.repository.baseTemperature.value ) self.distanceFeedRate.addTagBracketedLine('objectFirstLayerInfillTemperature', self.repository.baseTemperature.value ) self.distanceFeedRate.addTagBracketedLine('objectFirstLayerPerimeterTemperature', self.repository.baseTemperature.value ) self.distanceFeedRate.addTagBracketedLine('objectNextLayersTemperature', self.repository.baseTemperature.value ) self.distanceFeedRate.addTagBracketedLine('supportLayersTemperature', self.repository.baseTemperature.value ) self.distanceFeedRate.addTagBracketedLine('supportedLayersTemperature', self.repository.baseTemperature.value ) else: self.distanceFeedRate.addTagBracketedLine('interfaceTemperature', self.repository.interfaceTemperature.value ) self.distanceFeedRate.addTagBracketedLine('objectFirstLayerInfillTemperature', self.repository.objectFirstLayerInfillTemperature.value ) self.distanceFeedRate.addTagBracketedLine('objectFirstLayerPerimeterTemperature', self.repository.objectFirstLayerPerimeterTemperature.value ) self.distanceFeedRate.addTagBracketedLine('objectNextLayersTemperature', self.repository.objectNextLayersTemperature.value ) self.distanceFeedRate.addTagBracketedLine('supportLayersTemperature', self.repository.supportLayersTemperature.value ) self.distanceFeedRate.addTagBracketedLine('supportedLayersTemperature', self.repository.supportedLayersTemperature.value ) self.distanceFeedRate.addLine(line)
def parseInitialization(self): '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 == '(<layerThickness>': self.layerThickness = float(splitLine[1]) elif firstWord == '(</extruderInitialization>)': self.distanceFeedRate.addLine('(<procedureName> speed </procedureName>)') return elif firstWord == '(<perimeterWidth>': self.absolutePerimeterWidth = abs(float(splitLine[1])) self.distanceFeedRate.addTagBracketedLine('operatingFeedRatePerSecond', self.feedRatePerSecond ) self.distanceFeedRate.addTagBracketedLine('PerimeterFeedRatePerSecond', self.repository.perimeterFeedRateOverOperatingFeedRate ) if self.repository.addFlowRate.value: self.distanceFeedRate.addTagBracketedLine('operatingFlowRate', self.repository.flowRateSetting.value * self.repository.feedRatePerSecond.value ) self.distanceFeedRate.addTagBracketedLine('PerimeterFlowRate', self.repository.perimeterFlowRateOverOperatingFlowRate.value * self.repository.perimeterFeedRateOverOperatingFeedRate.value ) orbitalFeedRatePerSecond = self.feedRatePerSecond * self.repository.orbitalFeedRateOverOperatingFeedRate.value self.distanceFeedRate.addTagBracketedLine('orbitalFeedRatePerSecond', orbitalFeedRatePerSecond ) self.distanceFeedRate.addTagBracketedLine('travelFeedRatePerSecond', self.repository.travelFeedRatePerSecond.value ) elif firstWord == '(<nozzleDiameter>': self.nozzleDiameter = abs(float(splitLine[1])) self.distanceFeedRate.addLine(line)
def parseInitialization(self, clipRepository): "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.distanceFeedRate.addTagBracketedProcedure("clip") return elif firstWord == "(<perimeterWidth>": self.distanceFeedRate.addTagBracketedLine( "clipOverPerimeterWidth", clipRepository.clipOverPerimeterWidth.value ) self.perimeterWidth = float(splitLine[1]) absolutePerimeterWidth = abs(self.perimeterWidth) self.clipLength = ( clipRepository.clipOverPerimeterWidth.value * self.perimeterWidth * (euclidean.globalQuarterPi / 2) ) self.connectingStepLength = 0.5 * absolutePerimeterWidth self.layerPixelWidth = 0.24321 * absolutePerimeterWidth # todo check whether 1-0.25pi self.maximumConnectionDistance = ( clipRepository.maximumConnectionDistanceOverPerimeterWidth.value * absolutePerimeterWidth ) elif firstWord == "(<travelFeedRatePerSecond>": self.travelFeedRateMinute = 60.0 * float(splitLine[1]) self.distanceFeedRate.addLine(line)
def parseInitialization(self): "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.distanceFeedRate.addLine("(<procedureName> stretch </procedureName>)") return elif firstWord == "(<perimeterWidth>": perimeterWidth = float(splitLine[1]) self.crossLimitDistance = ( self.perimeterWidth * self.stretchRepository.crossLimitDistanceOverPerimeterWidth.value ) self.loopMaximumAbsoluteStretch = ( self.perimeterWidth * self.stretchRepository.loopStretchOverPerimeterWidth.value ) self.pathAbsoluteStretch = ( self.perimeterWidth * self.stretchRepository.pathStretchOverPerimeterWidth.value ) self.perimeterInsideAbsoluteStretch = ( self.perimeterWidth * self.stretchRepository.perimeterInsideStretchOverPerimeterWidth.value ) self.perimeterOutsideAbsoluteStretch = ( self.perimeterWidth * self.stretchRepository.perimeterOutsideStretchOverPerimeterWidth.value ) self.stretchFromDistance = ( self.stretchRepository.stretchFromDistanceOverPerimeterWidth.value * perimeterWidth ) self.threadMaximumAbsoluteStretch = self.pathAbsoluteStretch self.crossLimitDistanceFraction = 0.333333333 * self.crossLimitDistance self.crossLimitDistanceRemainder = self.crossLimitDistance - self.crossLimitDistanceFraction self.distanceFeedRate.addLine(line)
def parseInitialization(self): '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 == '(<decimalPlacesCarried>': # self.addInitializationToOutput() self.distanceFeedRate.addTagBracketedLine('bridgeWidthMultiplier', self.distanceFeedRate.getRounded( self.repository.bridgeWidthMultiplier.value )) self.distanceFeedRate.addTagBracketedLine('scaledBridgeWidthMultiplier', self.distanceFeedRate.getRounded( self.scaledBridgeWidthMultiplier )) elif firstWord == '(</extruderInitialization>)': self.distanceFeedRate.addTagBracketedProcedure('inset') return elif firstWord == '(<layerThickness>': self.layerThickness = float(splitLine[1]) elif firstWord == '(<perimeterWidth>': self.perimeterWidth = float(splitLine[1]) self.halfPerimeterWidth = 0.5 * self.perimeterWidth self.overlapRemovalWidth = self.perimeterWidth * self.repository.overlapRemovalWidthOverPerimeterWidth.value self.distanceFeedRate.addTagBracketedLine('nozzleDiameter', self.repository.nozzleDiameter.value ) self.nozzleXsection = (self.repository.nozzleDiameter.value/2) ** 2 * math.pi self.extrusionXsection = ((self.perimeterWidth + self.layerThickness)/4) ** 2 * math.pi self.distanceFeedRate.addTagBracketedLine('nozzleXsection', self.nozzleXsection) self.distanceFeedRate.addLine(line)
def parseInitialization(self): '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.distanceFeedRate.addTagBracketedProcedure('dimension') return elif firstWord == '(<layerThickness>': self.layerThickness = float(splitLine[1]) elif firstWord == '(<maximumZDrillFeedRatePerSecond>': self.maximumZFeedRatePerSecond = float(splitLine[1]) elif firstWord == '(<maximumZFeedRatePerSecond>': self.maximumZFeedRatePerSecond = float(splitLine[1]) elif firstWord == '(<operatingFeedRatePerSecond>': self.feedRateMinute = 60.0 * float(splitLine[1]) elif firstWord == '(<operatingFlowRate>': self.operatingFlowRate = float(splitLine[1]) self.flowRate = self.operatingFlowRate elif firstWord == '(<perimeterWidth>': self.perimeterWidth = float(splitLine[1]) elif firstWord == '(<travelFeedRatePerSecond>': self.travelFeedRatePerSecond = float(splitLine[1]) self.distanceFeedRate.addLine(line)
def getTransferClosestSurroundingLoopLines( self, oldOrderedLocation, remainingSurroundingLoops ): "Get and transfer the closest remaining surrounding loop." if len( remainingSurroundingLoops ) > 0: oldOrderedLocation.z = remainingSurroundingLoops[0].z closestDistance = 999999999999999999.0 closestSurroundingLoop = None for remainingSurroundingLoop in remainingSurroundingLoops: distance = euclidean.getNearestDistanceIndex( oldOrderedLocation.dropAxis(2), remainingSurroundingLoop.boundary ).distance if distance < closestDistance: closestDistance = distance closestSurroundingLoop = remainingSurroundingLoop remainingSurroundingLoops.remove( closestSurroundingLoop ) hasTravelledHighRoad = False for line in closestSurroundingLoop.lines: splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if firstWord == 'G1': location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) if not hasTravelledHighRoad: hasTravelledHighRoad = True self.addHighThread( location ) if location.z > self.highestZ: self.highestZ = location.z self.oldLocation = location self.distanceFeedRate.addLine(line) return closestSurroundingLoop
def parseInitialization(self): '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 == '(<decimalPlacesCarried>': self.addInitializationToOutput() self.distanceFeedRate.addTagBracketedLine('bridgeWidthMultiplier', self.distanceFeedRate.getRounded( self.repository.bridgeWidthMultiplier.value )) self.distanceFeedRate.addTagBracketedLine('scaledBridgeWidthMultiplier', self.distanceFeedRate.getRounded( self.scaledBridgeWidthMultiplier )) elif firstWord == '(</extruderInitialization>)': self.distanceFeedRate.addTagBracketedProcedure('inset') return elif firstWord == '(<layerHeight>': self.layerHeight = float(splitLine[1]) # self.infillWidth = self.repository.infillWidthOverThickness.value * self.layerHeight #moved dow so it is defined by edgeWidth # self.distanceFeedRate.addTagRoundedLine('infillWidth', self.infillWidth)#moved dow so it is defined by edgeWidth self.distanceFeedRate.addTagRoundedLine('volumeFraction', self.repository.volumeFraction.value) elif firstWord == '(<edgeWidth>': self.edgeWidth = float(splitLine[1]) self.infillWidth = self.edgeWidth self.halfEdgeWidth = 0.5 * self.edgeWidth self.overlapRemovalWidth = self.edgeWidth * euclidean.globalQuarterPi * self.repository.overlapRemovalWidthOverEdgeWidth.value self.distanceFeedRate.addTagBracketedLine('nozzleDiameter', self.repository.nozzleDiameter.value ) self.nozzleXsection = (self.repository.nozzleDiameter.value/2) ** 2 * math.pi self.extrusionXsection = ((self.edgeWidth + self.layerHeight)/4) ** 2 * math.pi self.distanceFeedRate.addTagBracketedLine('nozzleXsection', self.nozzleXsection) self.distanceFeedRate.addTagRoundedLine('infillWidth', self.infillWidth) self.distanceFeedRate.addLine(line)
def parseInitialization(self): "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 == "(<clipOverEdgeWidth>": self.clipOverEdgeWidth = float(splitLine[1]) elif firstWord == "(<edgeWidth>": self.edgeWidth = float(splitLine[1]) self.halfEdgeWidth = 0.5 * self.edgeWidth elif firstWord == "(</extruderInitialization>)": self.distanceFeedRate.addTagBracketedProcedure("skin") return elif firstWord == "(<infillPerimeterOverlap>": self.infillPerimeterOverlap = float(splitLine[1]) elif firstWord == "(<infillWidth>": self.infillWidth = float(splitLine[1]) self.skinInfillWidth = self.infillWidth / self.horizontalInfillDivisionsFloat elif firstWord == "(<layerHeight>": self.layerHeight = float(splitLine[1]) elif firstWord == "(<maximumZFeedRatePerSecond>": self.maximumZFeedRateMinute = 60.0 * float(splitLine[1]) elif firstWord == "(<operatingFlowRate>": self.oldFlowRate = float(splitLine[1]) elif firstWord == "(<sharpestProduct>": self.sharpestProduct = float(splitLine[1]) elif firstWord == "(<travelFeedRatePerSecond>": self.travelFeedRateMinute = 60.0 * float(splitLine[1]) self.distanceFeedRate.addLine(line)
def setCorners(self): 'Set maximum and minimum corners and z.' cornerMaximumComplex = complex(-987654321.0, -987654321.0) cornerMinimumComplex = -cornerMaximumComplex for line in self.lines[self.lineIndex :]: splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if firstWord == 'G1': location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) if self.isExtrusionActive: locationComplex = location.dropAxis() cornerMaximumComplex = euclidean.getMaximum(locationComplex, cornerMaximumComplex) cornerMinimumComplex = euclidean.getMinimum(locationComplex, cornerMinimumComplex) self.oldLocation = location elif firstWord == 'M101': self.isExtrusionActive = True elif firstWord == 'M103': self.isExtrusionActive = False self.extent = cornerMaximumComplex - cornerMinimumComplex self.shapeCenter = 0.5 * (cornerMaximumComplex + cornerMinimumComplex) self.separation = self.repository.separationOverPerimeterWidth.value * self.absolutePerimeterWidth self.extentPlusSeparation = self.extent + complex(self.separation, self.separation) columnsMinusOne = self.numberOfColumns - 1 rowsMinusOne = self.numberOfRows - 1 self.arrayExtent = complex(self.extentPlusSeparation.real * columnsMinusOne, self.extentPlusSeparation.imag * rowsMinusOne) self.arrayCenter = 0.5 * self.arrayExtent
def parseInitialization(self): '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.distanceFeedRate.addTagBracketedProcedure('dimension') return elif firstWord == '(<layerHeight>': self.layerHeight = float(splitLine[1]) elif firstWord == '(<maximumZDrillFeedRatePerSecond>': self.maximumZFeedRatePerSecond = float(splitLine[1]) elif firstWord == '(<maximumZFeedRatePerSecond>': self.maximumZFeedRatePerSecond = float(splitLine[1]) elif firstWord == '(<operatingFeedRatePerSecond>': self.feedRateMinute = 60.0 * float(splitLine[1]) elif firstWord == '(<operatingFlowRate>': self.operatingFlowRate = float(splitLine[1]) self.flowRate = self.operatingFlowRate elif firstWord == '(<edgeWidth>': self.edgeWidth = float(splitLine[1]) elif firstWord == '(<travelFeedRatePerSecond>': self.travelFeedRatePerSecond = float(splitLine[1]) elif firstWord == '(<FirstLayerTravelSpeed>': self.FirstLayerTravelSpeed = float(splitLine[1]) elif firstWord == '(<nozzleDiameter>': self.nozzleDiameter = float(splitLine[1]) self.nozzleXsection = (self.nozzleDiameter/2)**2*math.pi self.distanceFeedRate.addLine(line)
def parseBoundaries(self): "Parse the boundaries and add them to the boundary layers." boundaryLoop = None boundaryLayer = None for line in self.lines[self.lineIndex :]: splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if len(self.shutdownLines) > 0: self.shutdownLines.append(line) if firstWord == "(</boundaryPerimeter>)": boundaryLoop = None elif firstWord == "(<boundaryPoint>": location = gcodec.getLocationFromSplitLine(None, splitLine) if boundaryLoop == None: boundaryLoop = [] boundaryLayer.loops.append(boundaryLoop) boundaryLoop.append(location.dropAxis()) elif firstWord == "(<layer>": boundaryLayer = euclidean.LoopLayer(float(splitLine[1])) self.boundaryLayers.append(boundaryLayer) elif firstWord == "(</crafting>)": self.shutdownLines = [line] for boundaryLayer in self.boundaryLayers: if not euclidean.isWiddershins(boundaryLayer.loops[0]): boundaryLayer.loops[0].reverse() self.boundaryReverseLayers = self.boundaryLayers[:] self.boundaryReverseLayers.reverse()
def setEarlyStartupDistance(self, splitLine): "Set the early startup distance." if self.earlyStartupDistance is not None: return self.distanceFromThreadEndToThreadBeginning = 0.0 lastThreadLocation = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) if self.oldLocation is not None: self.distanceFromThreadEndToThreadBeginning = lastThreadLocation.distance(self.oldLocation) for afterIndex in xrange(self.lineIndex + 1, len(self.lines)): line = self.lines[afterIndex] splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if firstWord == "G1": location = gcodec.getLocationFromSplitLine(lastThreadLocation, splitLine) self.distanceFromThreadEndToThreadBeginning += location.distance(lastThreadLocation) lastThreadLocation = location elif firstWord == "M101": distanceConstantRatio = self.distanceFromThreadEndToThreadBeginning / self.earlyStartupDistanceConstant earlyStartupOperatingDistance = self.earlyStartupMaximumDistance * ( 1.0 - math.exp(-distanceConstantRatio) ) if self.isFirstExtrusion: earlyStartupOperatingDistance = self.oozebaneRepository.firstEarlyStartupDistance.value self.isFirstExtrusion = False self.earlyStartupDistance = earlyStartupOperatingDistance * self.getActiveFeedRateRatio() return
def parseInitialization(self): '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 == '(<clipOverPerimeterWidth>': self.clipOverPerimeterWidth = float(splitLine[1]) elif firstWord == '(</extruderInitialization>)': self.distanceFeedRate.addTagBracketedProcedure('skin') return elif firstWord == '(<infillPerimeterOverlap>': self.infillPerimeterOverlap = float(splitLine[1]) elif firstWord == '(<infillWidth>': self.infillWidth = float(splitLine[1]) self.skinInfillWidth = self.infillWidth / self.horizontalInfillDivisionsFloat elif firstWord == '(<layerThickness>': self.layerThickness = float(splitLine[1]) elif firstWord == '(<maximumZFeedRatePerSecond>': self.maximumZFeedRateMinute = 60.0 * float(splitLine[1]) elif firstWord == '(<operatingFlowRate>': self.oldFlowRate = float(splitLine[1]) elif firstWord == '(<perimeterWidth>': self.perimeterWidth = float(splitLine[1]) self.halfPerimeterWidth = 0.5 * self.perimeterWidth elif firstWord == '(<travelFeedRatePerSecond>': self.travelFeedRateMinute = 60.0 * float(splitLine[1]) self.distanceFeedRate.addLine(line)
def parseLine(self, line): "Parse a gcode line." binary16ByteRepository = self.binary16ByteRepository splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if len(firstWord) < 1: return firstLetter = firstWord[0] if firstLetter == '(': return feedRateInteger = getIntegerFromCharacterLengthLineOffset('F', 0.0, splitLine, binary16ByteRepository.feedRateStepLength.value ) iInteger = getIntegerFromCharacterLengthLineOffset('I', 0.0, splitLine, binary16ByteRepository.xStepLength.value ) jInteger = getIntegerFromCharacterLengthLineOffset('J', 0.0, splitLine, binary16ByteRepository.yStepLength.value ) xInteger = getIntegerFromCharacterLengthLineOffset('X', binary16ByteRepository.xOffset.value, splitLine, binary16ByteRepository.xStepLength.value ) yInteger = getIntegerFromCharacterLengthLineOffset('Y', binary16ByteRepository.yOffset.value, splitLine, binary16ByteRepository.yStepLength.value ) zInteger = getIntegerFromCharacterLengthLineOffset('Z', binary16ByteRepository.zOffset.value, splitLine, binary16ByteRepository.zStepLength.value ) sixteenByteStruct = Struct('cBhhhhhhBc') flagInteger = getIntegerFlagFromCharacterSplitLine('X', splitLine ) flagInteger += 2 * getIntegerFlagFromCharacterSplitLine('Y', splitLine ) flagInteger += 4 * getIntegerFlagFromCharacterSplitLine('Z', splitLine ) flagInteger += 8 * getIntegerFlagFromCharacterSplitLine('I', splitLine ) flagInteger += 16 * getIntegerFlagFromCharacterSplitLine('J', splitLine ) flagInteger += 32 * getIntegerFlagFromCharacterSplitLine('F', splitLine ) packedString = sixteenByteStruct.pack( firstLetter, int( firstWord[1 :] ), xInteger, yInteger, zInteger, iInteger, jInteger, feedRateInteger, flagInteger, '#') self.output.write( packedString )
def parseLine(self, line): 'Parse a gcode line.' splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if len(firstWord) < 1: return firstLetter = firstWord[0] if firstLetter == '(': return if firstWord != 'G1' and firstWord != 'G2' and firstWord != 'G3': self.addLine(line) return lineStringIO = cStringIO.StringIO() lineStringIO.write(firstWord) self.addCharacterInteger('I', lineStringIO, 0.0, splitLine, self.repository.xStepLength.value) self.addCharacterInteger('J', lineStringIO, 0.0, splitLine, self.repository.yStepLength.value) self.addCharacterInteger('R', lineStringIO, 0.0, splitLine, self.repository.radiusStepLength.value) self.addCharacterInteger('X', lineStringIO, self.repository.xOffset.value, splitLine, self.repository.xStepLength.value) self.addCharacterInteger('Y', lineStringIO, self.repository.yOffset.value, splitLine, self.repository.yStepLength.value) zString = getCharacterIntegerString('Z', self.repository.zOffset.value, splitLine, self.repository.zStepLength.value) feedRateString = getCharacterIntegerString('F', 0.0, splitLine, self.repository.feedRateStepLength.value) if zString != '': if zString != self.oldZString or self.repository.addZEvenWhenUnchanging.value: self.addStringToLine(lineStringIO, zString) if feedRateString != '': if feedRateString != self.oldFeedRateString or self.repository.addFeedRateEvenWhenUnchanging.value: self.addStringToLine(lineStringIO, feedRateString) self.addCharacterInteger('E', lineStringIO, 0.0, splitLine, self.repository.eStepLength.value) self.addLine(lineStringIO.getvalue()) self.oldFeedRateString = feedRateString self.oldZString = zString
def parseInitialization(self): "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 == "(<layerThickness>": self.layerThickness = float(splitLine[1]) elif firstWord == "(</extruderInitialization>)": self.distanceFeedRate.addLine("(<procedureDone> speed </procedureDone>)") return elif firstWord == "(<perimeterWidth>": self.absolutePerimeterWidth = abs(float(splitLine[1])) self.distanceFeedRate.addTagBracketedLine( "maximumZDrillFeedRatePerSecond", self.distanceFeedRate.maximumZDrillFeedRatePerSecond ) self.distanceFeedRate.addTagBracketedLine( "maximumZTravelFeedRatePerSecond", self.distanceFeedRate.maximumZTravelFeedRatePerSecond ) self.distanceFeedRate.addTagBracketedLine("operatingFeedRatePerSecond", self.feedRatePerSecond) if self.repository.addFlowRate.value: self.distanceFeedRate.addTagBracketedLine( "operatingFlowRate", self.repository.flowRateSetting.value ) orbitalFeedRatePerSecond = ( self.feedRatePerSecond * self.repository.orbitalFeedRateOverOperatingFeedRate.value ) self.distanceFeedRate.addTagBracketedLine("orbitalFeedRatePerSecond", orbitalFeedRatePerSecond) self.distanceFeedRate.addTagBracketedLine( "travelFeedRatePerSecond", self.repository.travelFeedRatePerSecond.value ) self.distanceFeedRate.addLine(line)
def parseInitialization(self): '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.distanceFeedRate.addLine('(<procedureName> leadin </procedureName>)') return elif firstWord == '(<infillWidth>': self.quarterInfillWidth = 0.25 * float(splitLine[1]) elif firstWord == '(<layerThickness>': self.LayerThickness = float(splitLine[1]) self.halfLayerThickness = 0.5 * float(splitLine[1]) elif firstWord == '(<operatingFlowRate>': self.oldFlowRate = float(splitLine[1]) elif firstWord == '(<perimeterWidth>': perimeterWidth = float(splitLine[1]) self.PerimeterWidth = perimeterWidth self.halfPerimeterWidth = 0.5 * perimeterWidth self.quarterPerimeterWidth = 0.25 * perimeterWidth self.clipLength = (self.repository.clipOverPerimeterWidth.value * self.halfLayerThickness * (0.7853))/2 elif firstWord == '(<travelFeedRatePerSecond>': self.travelFeedRateMinute = 60.0 * float(splitLine[1]) self.distanceFeedRate.addLine(line)
def getNext(self): "Get next line going backward or raise exception." while self.lineIndex > 3: if self.lineIndex == self.firstLineIndex: raise StopIteration, "You've reached the end of the line." if self.firstLineIndex == None: self.firstLineIndex = self.lineIndex nextLineIndex = self.lineIndex - 1 line = self.lines[ self.lineIndex ] splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if firstWord == 'M103': if self.isLoop: nextLineIndex = self.getIndexBeforeNextDeactivate() else: raise StopIteration, "You've reached the end of the line." if firstWord == 'G1': if self.isBeforeExtrusion(): if self.isLoop: nextLineIndex = self.getIndexBeforeNextDeactivate() else: raise StopIteration, "You've reached the end of the line." else: self.lineIndex = nextLineIndex return line self.lineIndex = nextLineIndex raise StopIteration, "You've reached the end of the line."
def isNextMovementReversalWorthy(self, threshold, starttoken, endtoken): """ Returns True if we should activate reversal on the next movement, False otherwise. The given threshold defines the movement distance under which we don't reverse. starttoken,endtoken is the movement delimiter (M101,M103 for thread, M103,M101 for stop) """ line = self.lines[self.lineIndex] splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) lastThreadLocation = gcodec.getLocationFromSplitLine(self.newLocation, splitLine) startTokenReached = False endTokenReached = False totalDistance = 0.0 for afterIndex in xrange(self.lineIndex + 1, len(self.lines)): line = self.lines[afterIndex] splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if firstWord == 'G1': location = gcodec.getLocationFromSplitLine(lastThreadLocation, splitLine) if startTokenReached: totalDistance += location.distance(lastThreadLocation) if totalDistance >= threshold: if DEBUG: self.distanceFeedRate.addLine("( Next movement worthy: " + str(totalDistance) + " )") return True lastThreadLocation = location elif firstWord == endtoken: endTokenReached = True if startTokenReached: return False elif firstWord == starttoken: startTokenReached = True return False
def parseBoundaries(self): 'Parse the boundaries and add them to the boundary layers.' self.boundaryLayers = [] self.layerIndexTop = -1 boundaryLoop = None boundaryLayer = None for line in self.lines[self.lineIndex :]: splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if firstWord == '(</boundaryPerimeter>)': boundaryLoop = None elif firstWord == '(<boundaryPoint>': location = gcodec.getLocationFromSplitLine(None, splitLine) if boundaryLoop == None: boundaryLoop = [] boundaryLayer.loops.append(boundaryLoop) boundaryLoop.append(location.dropAxis()) elif firstWord == '(<layer>': boundaryLayer = euclidean.LoopLayer(float(splitLine[1])) self.boundaryLayers.append(boundaryLayer) self.layerIndexTop += 1 for boundaryLayerIndex, boundaryLayer in enumerate(self.boundaryLayers): if len(boundaryLayer.loops) > 0: self.layersFromBottom += boundaryLayerIndex return
def parseInitialization(self): "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.distanceFeedRate.addTagBracketedProcedure("skirt") return elif firstWord == "(<objectNextLayersTemperature>": self.oldTemperatureInput = float(splitLine[1]) self.skirtTemperature = self.oldTemperatureInput elif firstWord == "(<operatingFeedRatePerSecond>": self.feedRateMinute = 60.0 * float(splitLine[1]) elif firstWord == "(<operatingFlowRate>": self.oldFlowRate = float(splitLine[1]) self.skirtFlowRate = self.oldFlowRate elif firstWord == "(<perimeterWidth>": self.perimeterWidth = float(splitLine[1]) self.skirtOutset = (self.repository.gapOverPerimeterWidth.value + 0.5) * self.perimeterWidth self.distanceFeedRate.addTagRoundedLine("skirtOutset", self.skirtOutset) elif firstWord == "(<travelFeedRatePerSecond>": self.travelFeedRateMinute = 60.0 * float(splitLine[1]) self.distanceFeedRate.addLine(line)
def getDistanceToNextThread(self, lineIndex): 'Get the travel distance to the next thread.' if self.oldLocation == None: return None isActive = False location = self.oldLocation for afterIndex in xrange(lineIndex + 1, len(self.lines)): line = self.lines[afterIndex] splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if firstWord == 'G1': if isActive: if not self.repository.retractWithinIsland.value: locationEnclosureIndex = self.getSmallestEnclosureIndex(location.dropAxis()) if locationEnclosureIndex != self.getSmallestEnclosureIndex(self.oldLocation.dropAxis()): return None locationMinusOld = location - self.oldLocation xyTravel = abs(locationMinusOld.dropAxis()) zTravelMultiplied = locationMinusOld.z * self.zDistanceRatio return math.sqrt(xyTravel * xyTravel + zTravelMultiplied * zTravelMultiplied) location = gcodec.getLocationFromSplitLine(location, splitLine) elif firstWord == 'M101': isActive = True elif firstWord == 'M103': isActive = False return None
def parseInitialization(self): """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.distanceFeedRate.addLine('(<procedureName> dimension </procedureName>)') return elif firstWord == '(<extrusionHeight>': self.extrusionHeight = float(splitLine[1]) elif firstWord == '(<maximumZDrillFeedRatePerSecond>': self.maximumZTravelFeedRate = float(splitLine[1]) elif firstWord == '(<maximumZTravelFeedRate>': self.maximumZTravelFeedRate = float(splitLine[1]) elif firstWord == '(<operatingFeedRatePerSecond>': self.feedRateMinute = 60.0 * float(splitLine[1]) elif firstWord == '(<operatingFlowRate>': self.operatingFlowRate = float(splitLine[1]) self.flowRate = self.operatingFlowRate elif firstWord == '(<extrusionWidth>': self.extrusionWidth = float(splitLine[1]) elif firstWord == '(<travelFeedRate>': self.travelFeedRate = float(splitLine[1]) self.distanceFeedRate.addLine(line)
def getTransferClosestNestedRingLines( self, oldOrderedLocation, remainingNestedRings ): "Get and transfer the closest remaining nested ring." if len( remainingNestedRings ) > 0: oldOrderedLocation.z = remainingNestedRings[0].z closestDistance = 999999999987654321.0 closestNestedRing = None for remainingNestedRing in remainingNestedRings: distance = euclidean.getClosestDistanceIndexToLine(oldOrderedLocation.dropAxis(), remainingNestedRing.boundary).distance if distance < closestDistance: closestDistance = distance closestNestedRing = remainingNestedRing remainingNestedRings.remove(closestNestedRing) hasTravelledHighRoad = False for line in closestNestedRing.lines: splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if firstWord == 'G1': location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) if not hasTravelledHighRoad: hasTravelledHighRoad = True self.addHighThread(location) if location.z > self.highestZ: self.highestZ = location.z self.oldLocation = location self.distanceFeedRate.addLine(line) return closestNestedRing
def getAbridgedSettings(gcodeText): 'Get the abridged settings from the gcode text.' abridgedSettings = [] lines = archive.getTextLines(gcodeText) settingsStart = False for line in lines: splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if firstWord == '(<setting>' and settingsStart: if len(splitLine) > 4: abridgedSettings.append(AbridgedSetting(splitLine)) elif firstWord == '(<settings>)': settingsStart = True elif firstWord == '(</settings>)': return abridgedSettings return []
def parseInitialization(self): "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.distanceFeedRate.addTagBracketedLine('procedureDone', 'widen') elif firstWord == '(<extrusion>)': self.distanceFeedRate.addLine(line) return elif firstWord == '(<perimeterWidth>': self.perimeterWidth = float(splitLine[1]) self.doublePerimeterWidth = 2.0 * self.perimeterWidth self.distanceFeedRate.addLine(line)
def parseInitialization( self, hopRepository ): '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 == '(<layerThickness>': layerThickness = float(splitLine[1]) self.hopHeight = hopRepository.hopOverLayerThickness.value * layerThickness self.hopDistance = self.hopHeight / self.minimumSlope self.minimumDistance = 0.5 * layerThickness elif firstWord == '(</extruderInitialization>)': self.distanceFeedRate.addLine('(<procedureDone> hop </procedureDone>)') return self.distanceFeedRate.addLine(line)
def parseInitialization(self): '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.distanceFeedRate.addLine( '(<procedureName> multiply </procedureName>)') self.distanceFeedRate.addLine(line) self.lineIndex += 1 return elif firstWord == '(<perimeterWidth>': self.absolutePerimeterWidth = abs(float(splitLine[1])) self.distanceFeedRate.addLine(line)
def parseInitialization(self): '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.distanceFeedRate.addLine('(<procedureName> feed </procedureName>)') return elif firstWord == '(<perimeterWidth>': self.absolutePerimeterWidth = abs(float(splitLine[1])) self.distanceFeedRate.addTagBracketedLine('maximumZDrillFeedRatePerSecond', self.repository.maximumZDrillFeedRatePerSecond.value) self.distanceFeedRate.addTagBracketedLine('operatingFeedRatePerSecond', self.feedRatePerSecond) self.distanceFeedRate.addTagBracketedLine('travelFeedRatePerSecond', self.repository.travelFeedRatePerSecond.value) self.distanceFeedRate.addLine(line)
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 parseInitialization(self): '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.distanceFeedRate.addTagBracketedProcedure('coil') return elif firstWord == '(<layerHeight>': self.layerHeight = float(splitLine[1]) elif firstWord == '(<edgeWidth>': self.edgeWidth = float(splitLine[1]) self.halfEdgeWidth = 0.5 * self.edgeWidth self.distanceFeedRate.addLine(line)
def parseInitialization(self): "Parse gcode initialization and store the parameters." for self.lineIndex in xrange(len(self.lines)): line = self.lines[self.lineIndex].lstrip() splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) self.distanceFeedRate.parseSplitLine(firstWord, splitLine) if firstWord == '(</extruderInitialization>)': self.distanceFeedRate.addTagBracketedLine( 'procedureDone', 'whittle') return elif firstWord == '(<layerThickness>': self.setLayerThinknessVerticalDeltas(splitLine) self.distanceFeedRate.addTagBracketedLine( 'layerStep', self.layerStep) self.distanceFeedRate.addLine(line)
def parseInitialization(self): 'Parse gcode initialization and store the parameters.' for self.lineIndex in xrange(len(self.lines)): line = self.lines[self.lineIndex].lstrip() splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) self.distanceFeedRate.parseSplitLine(firstWord, splitLine) if firstWord == '(</extruderInitialization>)': self.distanceFeedRate.addTagBracketedLine( 'procedureDone', 'lift') return elif firstWord == '(<layerThickness>': self.layerThickness = float(splitLine[1]) elif firstWord == '(<layerStep>': self.layerStep = float(splitLine[1]) self.distanceFeedRate.addLine(line)
def parseInitialization(self): "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.distanceFeedRate.addLine( '(<procedureDone> drill </procedureDone>)') return elif firstWord == '(<layerThickness>': self.halfLayerThickness = 0.5 * float(splitLine[1]) elif firstWord == '(<perimeterWidth>': self.maximumDistance = 0.1 * float(splitLine[1]) self.distanceFeedRate.addLine(line)
def parseInitialization(self, homeRepository): '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.distanceFeedRate.addLine( '(<procedureDone> home </procedureDone>)') return elif firstWord == '(<perimeterWidth>': self.absolutePerimeterWidth = abs(float(splitLine[1])) elif firstWord == '(<travelFeedRatePerSecond>': self.travelFeedRatePerMinute = 60.0 * float(splitLine[1]) self.distanceFeedRate.addLine(line)
def parseInitialization(self): "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.distanceFeedRate.addLine('(<procedureDone> dimension </procedureDone>)') return elif firstWord == '(<operatingFeedRatePerSecond>': self.feedRateMinute = 60.0 * float(splitLine[1]) elif firstWord == '(<operatingFlowRate>': self.operatingFlowRate = float(splitLine[1]) self.flowRate = self.operatingFlowRate self.distanceFeedRate.addLine(line)
def parseInitialization(self): '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 == '(<layerHeight>': self.layerHeight = float(splitLine[1]) elif firstWord == '(</extruderInitialization>)': self.distanceFeedRate.addTagBracketedProcedure('speed') return elif firstWord == '(<edgeWidth>': self.absoluteEdgeWidth = abs(float(splitLine[1])) self.distanceFeedRate.addTagBracketedLine( 'maximumZTravelFeedRatePerSecond', self.repository.maximumZFeedRatePerSecond.value) self.distanceFeedRate.addTagBracketedLine( 'objectFirstLayerFeedRateInfillMultiplier', self. repository.objectFirstLayerFeedRateInfillMultiplier.value) self.distanceFeedRate.addTagBracketedLine( 'operatingFeedRatePerSecond', self.feedRatePerSecond) self.distanceFeedRate.addTagBracketedLine( 'edgeFeedRatePerSecond', self.repository. edgeFeedRateMultiplier.value) #todo comment? if self.repository.addFlowRate.value: self.distanceFeedRate.addTagBracketedLine( 'objectFirstLayerFlowRateInfillMultiplier', self.repository. objectFirstLayerFlowRateInfillMultiplier.value) self.distanceFeedRate.addTagBracketedLine( 'operatingFlowRate', self.repository.flowRateSetting.value) orbitalFeedRatePerSecond = self.feedRatePerSecond * self.repository.orbitalFeedRateOverOperatingFeedRate.value self.distanceFeedRate.addTagBracketedLine( 'orbitalFeedRatePerSecond', orbitalFeedRatePerSecond) self.distanceFeedRate.addTagBracketedLine( 'travelFeedRatePerSecond', self.repository.travelFeedRatePerSecond.value) self.distanceFeedRate.addTagBracketedLine( 'FirstLayerTravelSpeed', self.repository.objectFirstLayerTravelSpeed.value) elif firstWord == '(<nozzleDiameter>': self.nozzleDiameter = float(splitLine[1]) elif firstWord == '(<nozzleXsection>': self.nozzleXsection = float(splitLine[1]) self.distanceFeedRate.addLine(line)
def parseInitialization(self): '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.distanceFeedRate.addTagBracketedProcedure('smooth') return elif firstWord == '(<infillWidth>': self.infillWidth = float(splitLine[1]) self.maximumShortening = self.repository.maximumShorteningOverWidth.value * self.infillWidth self.maximumDistance = 1.5 * self.maximumShortening elif firstWord == '(<travelFeedRatePerSecond>': self.travelFeedRateMinute = 60.0 * float(splitLine[1]) self.distanceFeedRate.addLine(line)
def parseInitialization(self, repository): '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.distanceFeedRate.addTagBracketedProcedure('fillet') return elif firstWord == '(<perimeterWidth>': perimeterWidth = abs(float(splitLine[1])) self.curveSection = 0.7 * perimeterWidth self.filletRadius = perimeterWidth * repository.filletRadiusOverPerimeterWidth.value self.minimumRadius = 0.1 * perimeterWidth self.reversalSlowdownDistance = perimeterWidth * repository.reversalSlowdownDistanceOverPerimeterWidth.value self.distanceFeedRate.addLine(line)
def setFeedRateLocationLoopPath(self, line, splitLine): 'Set the feedRateMinute, oldLocation and loopPath.' self.feedRateMinute = gcodec.getFeedRateMinute(self.feedRateMinute, splitLine) self.oldLocation = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine) if not self.isLoopPerimeter or self.loopPath != None: return for afterIndex in xrange(self.lineIndex + 1, len(self.lines)): line = self.lines[afterIndex] splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if firstWord == 'G1' or firstWord == 'M103': return elif firstWord == 'M101': self.loopPath = euclidean.PathZ(self.oldLocation.z) return
def parseInitialization(self, oozebaneRepository): '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.distanceFeedRate.addTagBracketedProcedure('oozebane') return elif firstWord == '(<operatingFeedRatePerSecond>': self.operatingFeedRateMinute = 60.0 * float(splitLine[1]) self.feedRateMinute = self.operatingFeedRateMinute elif firstWord == '(<perimeterWidth>': self.perimeterWidth = float(splitLine[1]) self.setExtrusionWidth(oozebaneRepository) self.distanceFeedRate.addLine(line)
def parseInitialization(self): '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.distanceFeedRate.addTagBracketedProcedure('widen') elif firstWord == '(<crafting>)': self.distanceFeedRate.addLine(line) return elif firstWord == '(<edgeWidth>': self.edgeWidth = float(splitLine[1]) self.widenEdgeWidth = float(self.repository.widenWidthOverEdgeWidth.value) * self.edgeWidth self.lessThanHalfEdgeWidth = 0.49 * self.edgeWidth self.distanceFeedRate.addLine(line)
def parseInitialization(self): "Parse gcode initialization and store the parameters." for self.lineIndex in xrange(len(self.lines)): line = self.lines[self.lineIndex].lstrip() splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) self.distanceFeedRate.parseSplitLine(firstWord, splitLine) if firstWord == '(</extruderInitialization>)': self.distanceFeedRate.addTagBracketedLine( 'procedureDone', 'outset') elif firstWord == '(<perimeterWidth>': self.absoluteHalfPerimeterWidth = 0.5 * abs(float( splitLine[1])) elif firstWord == '(<layer>': self.lineIndex -= 1 return self.distanceFeedRate.addLine(line)
def parseInitialization(self): '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 == '(<decimalPlacesCarried>': self.addInitializationToOutput() elif firstWord == '(</extruderInitialization>)': self.distanceFeedRate.addTagBracketedProcedure('inset') return elif firstWord == '(<perimeterWidth>': self.perimeterWidth = float(splitLine[1]) self.halfPerimeterWidth = 0.5 * self.perimeterWidth self.overlapRemovalWidth = self.perimeterWidth * self.repository.overlapRemovalWidthOverPerimeterWidth.value self.distanceFeedRate.addLine(line)
def setSettingDictionary(self): 'Set the setting dictionary from the gcode text.' for line in self.lines: splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if firstWord == '(<setting>' and self.settingDictionary != None: if len(splitLine) > 4: procedure = splitLine[1] name = splitLine[2].replace('_', ' ').replace(' ', '') if '(' in name: name = name[: name.find('(')] value = ' '.join(splitLine[3 : -1]) self.settingDictionary[(procedure + '.' + name).lower()] = value elif firstWord == '(<settings>)': self.settingDictionary = {} elif firstWord == '(</settings>)': return
def isBeforeExtrusion(self): "Determine if index is two or more before activate command." linearMoves = 0 for lineIndex in xrange(self.lineIndex + 1, len(self.lines)): line = self.lines[lineIndex] splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if firstWord == 'G1': linearMoves += 1 if firstWord == 'M101': return linearMoves > 0 if firstWord == 'M103': return False print( 'This should never happen in isBeforeExtrusion in stretch, no activate command was found for this thread.' ) return False
def parseLine(self, line): "Parse a gcode line." splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if len(firstWord) < 1: return firstLetter = firstWord[0] if firstWord == '(<operatingFeedRatePerSecond>': self.feedRateMinute = 60.0 * float(splitLine[1]) elif firstWord == '(<operatingFlowRate>': self.operatingFlowRate = float(splitLine[1]) self.flowRate = self.operatingFlowRate if firstLetter == '(': return if firstWord == 'M101': self.isExtruderActive = True elif firstWord == 'M103': self.isExtruderActive = False elif firstWord == 'M108': self.flowRate = float(splitLine[1][1 :]) if firstWord != 'G1' and firstWord != 'G2' and firstWord != 'G3': self.addLine(line) return self.feedRateMinute = gcodec.getFeedRateMinute(self.feedRateMinute, splitLine) lineStringIO = cStringIO.StringIO() lineStringIO.write(firstWord) location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) self.addCharacterInteger('X', lineStringIO, self.repository.xOffset.value, splitLine, self.repository.xStep.value ) self.addCharacterInteger('Y', lineStringIO, self.repository.yOffset.value, splitLine, self.repository.yStep.value ) zString = getCharacterIntegerString('Z', self.repository.zOffset.value, splitLine, self.repository.zStep.value ) if zString == None: zString = self.oldZString self.addStringToLine(lineStringIO, zString) duration = self.repository.initialTime.value if self.oldLocation != None: distance = abs(location - self.oldLocation) duration = 60.0 / self.feedRateMinute * distance extrusionDistance = 0.0 if self.isExtruderActive: extrusionDistance = self.flowRate * duration self.addStringToLine(lineStringIO, 'E%s' % int(round(extrusionDistance / self.repository.extrusionStep.value))) self.addStringToLine(lineStringIO, 'D%s' % int(round(duration * 1000000.0 / self.repository.timeStep.value))) self.addLine(lineStringIO.getvalue()) self.oldLocation = location self.oldZString = zString
def parseInitialization(self): '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.distanceFeedRate.addTagBracketedProcedure('comb') return elif firstWord == '(<edgeWidth>': self.edgeWidth = float(splitLine[1]) self.doubleEdgeWidth = self.edgeWidth + self.edgeWidth self.halfEdgeWidth = 0.5 * self.edgeWidth self.quadrupleEdgeWidth = self.doubleEdgeWidth + self.doubleEdgeWidth elif firstWord == '(<travelFeedRatePerSecond>': self.travelFeedRateMinute = 60.0 * float(splitLine[1]) self.distanceFeedRate.addLine(line)
def parseInitialization(self): '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.distanceFeedRate.addLine( '(<procedureDone> limit </procedureDone>)') return elif firstWord == '(<maximumZDrillFeedRatePerSecond>': self.maximumZDrillFeedRatePerSecond = float(splitLine[1]) elif firstWord == '(<perimeterWidth>': self.distanceFeedRate.addTagBracketedLine( 'maximumZTravelFeedRatePerSecond', self.maximumZTravelFeedRatePerSecond) self.distanceFeedRate.addLine(line)
def parseInitialization(self): '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.distanceFeedRate.addTagBracketedProcedure('mill') return elif firstWord == '(<perimeterWidth>': self.perimeterWidth = float(splitLine[1]) self.aroundWidth = 0.1 * self.perimeterWidth self.halfPerimeterWidth = 0.5 * self.perimeterWidth self.millWidth = self.perimeterWidth * self.repository.millWidthOverPerimeterWidth.value self.loopInnerOutset = self.halfPerimeterWidth + self.perimeterWidth * self.repository.loopInnerOutsetOverPerimeterWidth.value self.loopOuterOutset = self.halfPerimeterWidth + self.perimeterWidth * self.repository.loopOuterOutsetOverPerimeterWidth.value self.distanceFeedRate.addLine(line)
def parseInitialization(self, combRepository): '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.distanceFeedRate.addTagBracketedProcedure('comb') return elif firstWord == '(<perimeterWidth>': perimeterWidth = float(splitLine[1]) self.combInset = 0.7 * perimeterWidth self.betweenInset = 0.4 * perimeterWidth self.uTurnWidth = 0.5 * self.betweenInset elif firstWord == '(<travelFeedRatePerSecond>': self.travelFeedRateMinute = 60.0 * float(splitLine[1]) self.distanceFeedRate.addLine(line)
def parseInitialization(self, jitterRepository): '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.distanceFeedRate.addTagBracketedProcedure('jitter') return elif firstWord == '(<operatingFeedRatePerSecond>': self.operatingFeedRatePerMinute = 60.0 * float(splitLine[1]) elif firstWord == '(<perimeterWidth>': self.perimeterWidth = float(splitLine[1]) self.jitter = jitterRepository.jitterOverPerimeterWidth.value * self.perimeterWidth elif firstWord == '(<travelFeedRatePerSecond>': self.travelFeedRateMinute = 60.0 * float(splitLine[1]) self.distanceFeedRate.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('(<procedureDone> splodge </procedureDone>)') 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): '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.distanceFeedRate.addTagBracketedProcedure('tower') elif firstWord == '(<layer>': return elif firstWord == '(<layerHeight>': self.minimumBelow = 0.1 * float(splitLine[1]) elif firstWord == '(<edgeWidth>': self.edgeWidth = float(splitLine[1]) elif firstWord == '(<travelFeedRatePerSecond>': self.travelFeedRateMinute = 60.0 * float(splitLine[1]) self.distanceFeedRate.addLine(line)