def parseLine(self, line): 'Parse a gcode line and add it to the mill skein.' splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) if len(splitLine) < 1: return firstWord = splitLine[0] if firstWord == 'G1': location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) if self.isExtruderActive: self.average.addValue(location.z) if self.oldLocation != None: euclidean.addValueSegmentToPixelTable( self.oldLocation.dropAxis(), location.dropAxis(), self.aroundPixelTable, None, self.aroundWidth ) self.oldLocation = location elif firstWord == 'M101': self.isExtruderActive = True elif firstWord == 'M103': self.isExtruderActive = False elif firstWord == '(<layer>': settings.printProgress(self.layerIndex, 'mill') self.aroundPixelTable = {} self.average.reset() elif firstWord == '(</layer>)': if len(self.boundaryLayers) > self.layerIndex: self.addMillThreads() self.layerIndex += 1 self.distanceFeedRate.addLine(line)
def parseLine(self, line): "Parse a gcode line and add it to the dwindle skein." splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) if len(splitLine) < 1: return firstWord = splitLine[0] if firstWord == "G1": self.feedRateMinute = gcodec.getFeedRateMinute(self.feedRateMinute, splitLine) location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) if self.isActive: self.threadSections.append( ThreadSection(self.feedRateMinute, self.oldFlowRate, location, self.oldLocation) ) self.oldLocation = location elif firstWord == "(<layer>": self.layerIndex += 1 settings.printProgress(self.layerIndex, "dwindle") elif firstWord == "M101": self.isActive = True elif firstWord == "M103": self.isActive = False self.addThread() elif firstWord == "M108": self.oldFlowRate = gcodec.getDoubleAfterFirstLetter(splitLine[1]) if len(self.threadSections) == 0: self.distanceFeedRate.addLine(line)
def parseLine(self, lineIndex): 'Parse a gcode line and add it to the dimension skein.' line = self.lines[lineIndex].lstrip() splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) if len(splitLine) < 1: return firstWord = splitLine[0] if firstWord == 'G2' or firstWord == 'G3': line = self.getDimensionedArcMovement(line, splitLine) if firstWord == 'G1': line = self.getDimensionedLinearMovement(line, splitLine) if firstWord == 'G90': self.absoluteDistanceMode = True elif firstWord == 'G91': self.absoluteDistanceMode = False elif firstWord == '(<layer>': self.layerIndex += 1 settings.printProgress(self.layerIndex, 'dimension') elif firstWord == 'M101': self.addLinearMoveExtrusionDistanceLine(self.restartDistance * self.retractionRatio) if self.totalExtrusionDistance > self.repository.maximumEValueBeforeReset.value: if not self.repository.relativeExtrusionDistance.value: self.distanceFeedRate.addLine('G92 E0') self.totalExtrusionDistance = 0.0 self.isExtruderActive = True elif firstWord == 'M103': self.retractionRatio = self.getRetractionRatio(lineIndex) self.addLinearMoveExtrusionDistanceLine( -self.repository.retractionDistance.value * self.retractionRatio) self.isExtruderActive = False elif firstWord == 'M108': self.flowRate = float(splitLine[1][1:]) self.distanceFeedRate.addLine(line)
def parseLine(self, line): "Parse a gcode line and add it to the speed skein." splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) if len(splitLine) < 1: return firstWord = splitLine[0] if firstWord == '(<crafting>)': self.distanceFeedRate.addLine(line) self.addParameterString('M113', self.repository.dutyCycleAtBeginning.value ) # Set duty cycle . return elif firstWord == 'G1': line = self.getSpeededLine(line, splitLine) elif firstWord == 'M101': self.isExtruderActive = True elif firstWord == 'M103': self.isExtruderActive = False elif firstWord == '(<bridgeRotation>': self.isBridgeLayer = True elif firstWord == '(<layer>': self.layerIndex += 1 settings.printProgress(self.layerIndex, 'speed') self.isBridgeLayer = False self.addFlowRateLine() elif firstWord == '(<edge>' or firstWord == '(<edgePath>)': self.isEdgePath = True elif firstWord == '(</edge>)' or firstWord == '(</edgePath>)': self.isEdgePath = False self.distanceFeedRate.addLine(line)
def parseLine(self, line): 'Parse a gcode line and add it to the joris skein.' splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) if len(splitLine) < 1: return firstWord = splitLine[0] if firstWord == 'G1' and self.doJoris: self.feedRateMinute = gcodec.getFeedRateMinute(self.feedRateMinute, splitLine) location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) self.oldLocation = location if self.perimeter != None: self.perimeter.append(location.dropAxis()) return elif firstWord == '(<layer>': self.layerIndex += 1 settings.printProgress(self.layerIndex, 'joris') elif firstWord == 'M108': self.oldFlowRate = gcodec.getDoubleAfterFirstLetter(splitLine[1]) elif firstWord == '(<edge>': if self.layerIndex >= self.layersFromBottom: self.doJoris = True elif firstWord == 'M101' and self.doJoris: self.perimeter = [] return elif firstWord == 'M103' and self.doJoris: self.addJorisedPerimeter() return elif firstWord == '(</edge>)': self.doJoris = False self.distanceFeedRate.addLine(line)
def parseLine(self, line): 'Parse a gcode line and add it to the dwindle skein.' splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) if len(splitLine) < 1: return firstWord = splitLine[0] if firstWord == 'G1': self.feedRateMinute = gcodec.getFeedRateMinute( self.feedRateMinute, splitLine) location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) if self.isActive: self.threadSections.append( ThreadSection(self.feedRateMinute, self.oldFlowRate, location, self.oldLocation)) self.oldLocation = location elif firstWord == '(<layer>': self.layerIndex += 1 settings.printProgress(self.layerIndex, 'dwindle') elif firstWord == 'M101': self.isActive = True elif firstWord == 'M103': self.isActive = False self.addThread() elif firstWord == 'M108': self.oldFlowRate = gcodec.getDoubleAfterFirstLetter(splitLine[1]) if len(self.threadSections) == 0: self.distanceFeedRate.addLine(line)
def parseLine( self, lineIndex ): 'Parse a gcode line and add it to the dimension skein.' line = self.lines[lineIndex].lstrip() splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) if len(splitLine) < 1: return firstWord = splitLine[0] if firstWord == 'G2' or firstWord == 'G3': line = self.getDimensionedArcMovement( line, splitLine ) if firstWord == 'G1': line = self.getDimensionedLinearMovement( line, splitLine ) if firstWord == 'G90': self.absoluteDistanceMode = True elif firstWord == 'G91': self.absoluteDistanceMode = False elif firstWord == '(<layer>': self.layerIndex += 1 settings.printProgress(self.layerIndex, 'dimension') elif firstWord == 'M101': self.addLinearMoveExtrusionDistanceLine(self.restartDistance * self.retractionRatio) if self.totalExtrusionDistance > self.repository.maximumEValueBeforeReset.value: if not self.repository.relativeExtrusionDistance.value: self.distanceFeedRate.addLine('G92 E0') self.totalExtrusionDistance = 0.0 self.isExtruderActive = True elif firstWord == 'M103': self.retractionRatio = self.getRetractionRatio(lineIndex) self.addLinearMoveExtrusionDistanceLine(-self.repository.retractionDistance.value * self.retractionRatio) self.isExtruderActive = False elif firstWord == 'M108': self.flowRate = float( splitLine[1][1 :] ) self.distanceFeedRate.addLine(line)
def parseLine(self, line): 'Parse a gcode line and add it to the raft skein.self.' splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) if len(splitLine) < 1: return firstWord = splitLine[0] if firstWord == '(<baseLayer>)': self.isBaseLayer = True elif firstWord == '(</baseLayer>)': self.isBaseLayer = False elif firstWord == '(</crafting>)': self.extrusionStart = False elif firstWord == '(<edge>' or firstWord == '(<edgePath>)': self.isEdgePath = True elif firstWord == '(</edge>)' or firstWord == '(</edgePath>)': self.isEdgePath = False elif firstWord == 'G1': if self.extrusionStart: self.addTemperatureLineIfDifferent(self.getTemperature()) elif firstWord == '(<interfaceLayer>)': self.isInterfaceLayer = True elif firstWord == '(</interfaceLayer>)': self.isInterfaceLayer = False elif firstWord == '(<layer>' and not self.isRaft: self.layerIndex += 1 settings.printProgress(self.layerIndex, 'temperature') if self.threadSequenceFirstString == 'edge': self.isEdgePath = True elif firstWord == '(<raftLayerEnd>': self.isRaft = False elif firstWord == '(<supportLayer>)': self.isSupportLayer = True elif firstWord == '(</supportLayer>)': self.isSupportLayer = False self.distanceFeedRate.addLine(line)
def getZAddExtruderPaths(self, z): 'Get next z and add extruder loops.' settings.printProgress(len(self.rotatedLoopLayers), 'slice') rotatedLoopLayer = euclidean.RotatedLoopLayer(z) rotatedLoopLayer.loops = getEmptyZLoops(self.archivableObjects, self.importRadius, True, z, self.zoneArrangement) return triangle_mesh.getZAddExtruderPathsBySolidCarving( rotatedLoopLayer, self, z)
def addLoopLayerToOutput( self, layerIndex, threadLayer ): 'Add rotated boundary layer to the output.' settings.printProgress(self.layerIndex, 'vectorwrite') self.addLayerBegin( layerIndex, threadLayer ) transformString = self.getTransformString() self.pathDictionary['d'] = self.getSVGStringForLoops( threadLayer.boundaryLoops ) self.pathDictionary['transform'] = transformString self.addPaths('#fa0', threadLayer.innerPerimeters, transformString ) #orange self.addPaths('#ff0', threadLayer.loops, transformString ) #yellow self.addPaths('#f00', threadLayer.outerPerimeters, transformString ) #red self.addPaths('#f5c', threadLayer.paths, transformString ) #light violetred
def getZAddExtruderPaths( self, z ): "Get next z and add extruder loops." settings.printProgress(len(self.rotatedBoundaryLayers), 'slice') rotatedBoundaryLayer = self.getEmptyZExtruderPaths(True, z) self.rotatedBoundaryLayers.append( rotatedBoundaryLayer ) if self.bridgeLayerThickness == None: return z + self.layerThickness allExtrudateLoops = [] for loop in rotatedBoundaryLayer.loops: allExtrudateLoops += trianglemesh.getBridgeLoops( self.layerThickness, loop ) rotatedBoundaryLayer.rotation = trianglemesh.getBridgeDirection( self.belowLoops, allExtrudateLoops, self.layerThickness ) self.belowLoops = allExtrudateLoops if rotatedBoundaryLayer.rotation == None: return z + self.layerThickness return z + self.bridgeLayerThickness
def getZAddExtruderPaths( self, z ): 'Get next z and add extruder loops.' settings.printProgress(len(self.rotatedLoopLayers), 'slice') rotatedLoopLayer = euclidean.RotatedLoopLayer(z) self.rotatedLoopLayers.append( rotatedLoopLayer ) rotatedLoopLayer.loops = self.getLoopsFromMesh( getEmptyZ( self, z ) ) if self.bridgeLayerThickness == None: return z + self.layerThickness allExtrudateLoops = [] for loop in rotatedLoopLayer.loops: allExtrudateLoops += getBridgeLoops( self.layerThickness, loop ) rotatedLoopLayer.rotation = getBridgeDirection( self.belowLoops, allExtrudateLoops, self.layerThickness ) self.belowLoops = allExtrudateLoops if rotatedLoopLayer.rotation == None: return z + self.layerThickness return z + self.bridgeLayerThickness
def getZAddExtruderPaths( self, z ): "Get next z and add extruder loops." settings.printProgress(len(self.rotatedBoundaryLayers), 'slice') rotatedBoundaryLayer = euclidean.RotatedLoopLayer(z) self.rotatedBoundaryLayers.append( rotatedBoundaryLayer ) rotatedBoundaryLayer.loops = self.getLoopsFromMesh( getEmptyZ( self, z ) ) if self.bridgeLayerThickness == None: return z + self.layerThickness allExtrudateLoops = [] for loop in rotatedBoundaryLayer.loops: allExtrudateLoops += getBridgeLoops( self.layerThickness, loop ) rotatedBoundaryLayer.rotation = getBridgeDirection( self.belowLoops, allExtrudateLoops, self.layerThickness ) self.belowLoops = allExtrudateLoops if rotatedBoundaryLayer.rotation == None: return z + self.layerThickness return z + self.bridgeLayerThickness
def parseLine(self, line): 'Parse a gcode line and add it to the skin skein.' splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) if len(splitLine) < 1: return firstWord = splitLine[0] if firstWord == 'G1': self.feedRateMinute = gcodec.getFeedRateMinute( self.feedRateMinute, splitLine) self.oldLocation = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine) if self.infillBoundaries != None: return if self.edge != None: self.edge.append(self.oldLocation.dropAxis()) return elif firstWord == '(<infill>)': if self.layerIndex >= self.layersFromBottom and self.layerIndex == self.layerIndexTop: self.infillBoundaries = [] elif firstWord == '(</infill>)': self.addSkinnedInfill() elif firstWord == '(<infillBoundary>)': if self.infillBoundaries != None: self.infillBoundary = [] self.infillBoundaries.append(self.infillBoundary) elif firstWord == '(<infillPoint>': if self.infillBoundaries != None: location = gcodec.getLocationFromSplitLine(None, splitLine) self.infillBoundary.append(location.dropAxis()) elif firstWord == '(<layer>': self.layerIndex += 1 settings.printProgress(self.layerIndex, 'skin') elif firstWord == 'M101' or firstWord == 'M103': if self.infillBoundaries != None or self.edge != None: return elif firstWord == 'M108': self.oldFlowRate = gcodec.getDoubleAfterFirstLetter(splitLine[1]) elif firstWord == '(<edge>': if self.layerIndex >= self.layersFromBottom: self.edge = [] elif firstWord == '(<rotation>': self.rotation = gcodec.getRotationBySplitLine(splitLine) self.reverseRotation = complex(self.rotation.real, -self.rotation.imag) elif firstWord == '(</edge>)': self.addSkinnedPerimeter() self.distanceFeedRate.addLine(line)
def parseLine(self, line): 'Parse a gcode line and add it to the skin skein.' splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) if len(splitLine) < 1: return firstWord = splitLine[0] if firstWord == 'G1': self.feedRateMinute = gcodec.getFeedRateMinute(self.feedRateMinute, splitLine) location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) self.oldLocation = location if self.infillBoundaries != None: return if self.perimeter != None: self.perimeter.append(location.dropAxis()) return elif firstWord == '(<infill>)': if self.layerIndex >= self.layersFromBottom and self.layerIndex == self.layerIndexTop: self.infillBoundaries = [] elif firstWord == '(</infill>)': self.addSkinnedInfill() elif firstWord == '(<infillBoundary>)': if self.infillBoundaries != None: self.infillBoundary = [] self.infillBoundaries.append(self.infillBoundary) elif firstWord == '(<infillPoint>': if self.infillBoundaries != None: location = gcodec.getLocationFromSplitLine(None, splitLine) self.infillBoundary.append(location.dropAxis()) elif firstWord == '(<layer>': self.layerIndex += 1 settings.printProgress(self.layerIndex, 'skin') elif firstWord == 'M101' or firstWord == 'M103': if self.infillBoundaries != None or self.perimeter != None: return elif firstWord == 'M108': self.oldFlowRate = gcodec.getDoubleAfterFirstLetter(splitLine[1]) elif firstWord == '(<perimeter>': if self.layerIndex >= self.layersFromBottom: self.perimeter = [] elif firstWord == '(<rotation>': self.rotation = gcodec.getRotationBySplitLine(splitLine) self.reverseRotation = complex(self.rotation.real, -self.rotation.imag) elif firstWord == '(</perimeter>)': self.addSkinnedPerimeter() self.distanceFeedRate.addLine(line)
def parseLine(self, line): "Parse a gcode line and add it to the bevel gcode." splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) if len(splitLine) < 1: return firstWord = splitLine[0] if firstWord == 'G1': self.addWipeTravel(splitLine) self.oldLocation = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) elif firstWord == '(<layer>': settings.printProgress(self.layerIndex, 'wipe') self.layerIndex += 1 if self.layerIndex % self.wipePeriod == 0: self.shouldWipe = True elif firstWord == 'M101': self.extruderActive = True elif firstWord == 'M103': self.extruderActive = False self.distanceFeedRate.addLine(line)
def addLayer(self): 'Add multiplied layer to the output.' self.addRemoveThroughLayer() offset = self.centerOffset - self.arrayCenter - self.shapeCenter for rowIndex in xrange(self.repository.numberOfRows.value): yRowOffset = float(rowIndex) * self.extentPlusSeparation.imag if self.layerIndex % 2 == 1 and self.repository.reverseSequenceEveryOddLayer.value: yRowOffset = self.arrayExtent.imag - yRowOffset for columnIndex in xrange(self.repository.numberOfColumns.value): xColumnOffset = float(columnIndex) * self.extentPlusSeparation.real if self.rowIndex % 2 == 1: xColumnOffset = self.arrayExtent.real - xColumnOffset elementOffset = complex(offset.real + xColumnOffset, offset.imag + yRowOffset) self.addElement(elementOffset) self.rowIndex += 1 settings.printProgress(self.layerIndex, 'multiply') if len(self.layerLines) > 1: self.layerIndex += 1 self.layerLines = []
def parseLine(self, line): "Parse a gcode line and add it to the bevel gcode." splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) if len(splitLine) < 1: return firstWord = splitLine[0] if firstWord == 'G1': self.addWipeTravel(splitLine) self.oldLocation = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) elif firstWord == '(<layer>': self.layerIndex += 1 settings.printProgress(self.layerIndex, 'wipe') if self.layerIndex % self.wipePeriod == 0: self.shouldWipe = True elif firstWord == 'M101': self.extruderActive = True elif firstWord == 'M103': self.extruderActive = False self.distanceFeedRate.addLine(line)
def parseBoundaries(self): 'Parse the boundaries and union them.' self.createSegmentDictionaries(self.unifiedLoop) if self.repository.layersTo.value < 1: return loopCrossDictionary = None layerIndex = -1 for line in self.lines[self.lineIndex:]: splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if firstWord == '(</boundaryPerimeter>)' or firstWord == '(</raftPerimeter>)': self.createSegmentDictionaries(loopCrossDictionary) self.unifyLayer(loopCrossDictionary) loopCrossDictionary = None elif firstWord == '(<boundaryPoint>' or firstWord == '(<raftPoint>': location = gcodec.getLocationFromSplitLine(None, splitLine) if loopCrossDictionary == None: loopCrossDictionary = LoopCrossDictionary() loopCrossDictionary.loop.append(location.dropAxis()) elif firstWord == '(<layer>': layerIndex += 1 if layerIndex > self.repository.layersTo.value: return settings.printProgress(layerIndex, 'skirt')
def parseBoundaries(self): "Parse the boundaries and union them." self.createSegmentDictionaries(self.unifiedLoop) if self.repository.layersTo.value < 1: return loopCrossDictionary = None layerIndex = -1 for line in self.lines[self.lineIndex :]: splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if firstWord == "(</boundaryPerimeter>)" or firstWord == "(</raftPerimeter>)": self.createSegmentDictionaries(loopCrossDictionary) self.unifyLayer(loopCrossDictionary) loopCrossDictionary = None elif firstWord == "(<boundaryPoint>" or firstWord == "(<raftPoint>": location = gcodec.getLocationFromSplitLine(None, splitLine) if loopCrossDictionary == None: loopCrossDictionary = LoopCrossDictionary() loopCrossDictionary.loop.append(location.dropAxis()) elif firstWord == "(<layer>": layerIndex += 1 if layerIndex > self.repository.layersTo.value: return settings.printProgress(layerIndex, "skirt")
def getLoopLayerAppend(loopLayers, z): 'Get next z and add extruder loops.' settings.printProgress(len(loopLayers), 'slice') loopLayer = euclidean.LoopLayer(z) loopLayers.append(loopLayer) return loopLayer
def getZAddExtruderPaths(self, z): 'Get next z and add extruder loops.' settings.printProgress(len(self.rotatedLoopLayers), 'slice') rotatedLoopLayer = euclidean.RotatedLoopLayer(z) rotatedLoopLayer.loops = self.getLoopsFromMesh(getEmptyZ( self, z )) return getZAddExtruderPathsBySolidCarving(rotatedLoopLayer, self, z)
def getZAddExtruderPaths(self, z): """Get next z and add extruder loops.""" settings.printProgress(len(self.rotatedLoopLayers), 'slice') rotatedLoopLayer = euclidean.RotatedLoopLayer(z) rotatedLoopLayer.loops = getEmptyZLoops(self.archivableObjects, self.importRadius, True, z, self.zoneArrangement) return triangle_mesh.getZAddExtruderPathsBySolidCarving(rotatedLoopLayer, self, z)
def getZAddExtruderPaths(self, z): "Get next z and add extruder loops." settings.printProgress(len(self.rotatedLoopLayers), "slice") rotatedLoopLayer = euclidean.RotatedLoopLayer(z) rotatedLoopLayer.loops = self.getLoopsFromMesh(self.zoneArrangement.getEmptyZ(z)) return getZAddExtruderPathsBySolidCarving(rotatedLoopLayer, self, z)
def getZAddExtruderPaths(self, z): 'Get next z and add extruder loops.' settings.printProgress(len(self.rotatedLoopLayers), 'slice') rotatedLoopLayer = self.getEmptyZExtruderPaths(True, z) return triangle_mesh.getZAddExtruderPathsBySolidCarving(rotatedLoopLayer, self, z)