本文整理汇总了Python中skeinforge_tools.skeinforge_utilities.gcodec.getSplitLineBeforeBracketSemicolon函数的典型用法代码示例。如果您正苦于以下问题:Python getSplitLineBeforeBracketSemicolon函数的具体用法?Python getSplitLineBeforeBracketSemicolon怎么用?Python getSplitLineBeforeBracketSemicolon使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getSplitLineBeforeBracketSemicolon函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getDistanceToThreadBeginningAfterThreadEnd
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
示例2: isNextExtruderOn
def isNextExtruderOn(self):
"Determine if there is an extruder on command before a move command."
line = self.lines[self.lineIndex]
splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
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 False
elif firstWord == "M101":
return True
return False
示例3: parseStretch
def parseStretch( self, line ):
"Parse a gcode line and add it to the stretch skein."
splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
if len( splitLine ) < 1:
return
firstWord = splitLine[ 0 ]
if firstWord == 'G1':
line = self.getStretchedLine( splitLine )
elif firstWord == 'M101':
self.extruderActive = True
elif firstWord == 'M103':
self.extruderActive = False
self.setStretchToPath()
elif firstWord == '(<loop>':
self.isLoop = True
self.threadMaximumAbsoluteStretch = self.loopMaximumAbsoluteStretch
elif firstWord == '(</loop>)':
self.setStretchToPath()
elif firstWord == '(<perimeter>':
self.isLoop = True
self.threadMaximumAbsoluteStretch = self.perimeterInsideAbsoluteStretch
if splitLine[ 1 ] == 'outer':
self.threadMaximumAbsoluteStretch = self.perimeterOutsideAbsoluteStretch
elif firstWord == '(</perimeter>)':
self.setStretchToPath()
self.distanceFeedRate.addLine( line )
示例4: getSplodgeLineGivenDistance
def getSplodgeLineGivenDistance( self, feedRateMinute, line, liftOverExtraThickness, location, startupDistance ):
"Add the splodge line."
locationComplex = location.dropAxis( 2 )
relativeStartComplex = None
nextLocationComplex = self.getNextActiveLocationComplex()
if nextLocationComplex != None:
if nextLocationComplex != locationComplex:
relativeStartComplex = locationComplex - nextLocationComplex
if relativeStartComplex == None:
relativeStartComplex = complex( 19.9, 9.9 )
if self.oldLocation != None:
oldLocationComplex = self.oldLocation.dropAxis( 2 )
if oldLocationComplex != locationComplex:
relativeStartComplex = oldLocationComplex - locationComplex
relativeStartComplex *= startupDistance / abs( relativeStartComplex )
startComplex = self.getStartInsideBoundingRectangle( locationComplex, relativeStartComplex )
feedRateMultiplier = feedRateMinute / self.operatingFeedRatePerSecond / 60.0
splodgeLayerThickness = self.layerThickness / math.sqrt( feedRateMultiplier )
extraLayerThickness = splodgeLayerThickness - self.layerThickness
lift = extraLayerThickness * liftOverExtraThickness
startLine = self.distanceFeedRate.getLinearGcodeMovementWithFeedRate( self.feedRateMinute, startComplex, location.z + lift )
self.addLineUnlessIdenticalReactivate( startLine )
self.addLineUnlessIdenticalReactivate( 'M101' )
splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
lineLocation = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
self.distanceFeedRate.addGcodeMovementZWithFeedRate( feedRateMinute, locationComplex, lineLocation.z + lift )
return ''
示例5: parseLine
def parseLine( self, line ):
"Parse a gcode line and add it to the vector output."
splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
if len( splitLine ) < 1:
return
firstWord = splitLine[ 0 ]
if self.isLayerStart( firstWord, splitLine ):
self.extrusionNumber = 0
self.skeinPane = []
self.skeinPanes.append( self.skeinPane )
if firstWord == 'G1':
location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
self.linearMove( line, location )
self.oldLocation = location
elif firstWord == 'M101':
self.extruderActive = True
self.extrusionNumber += 1
elif firstWord == 'M103':
self.extruderActive = False
if firstWord == 'G2' or firstWord == 'G3':
relativeLocation = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
relativeLocation.z = 0.0
location = self.oldLocation + relativeLocation
self.linearMove( line, location )
self.oldLocation = location
示例6: parseLine
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.gcodeStepRepository.xStepLength.value )
self.addCharacterInteger( 'J', lineStringIO, 0.0, splitLine, self.gcodeStepRepository.yStepLength.value )
self.addCharacterInteger( 'R', lineStringIO, 0.0, splitLine, self.gcodeStepRepository.radiusStepLength.value )
self.addCharacterInteger( 'X', lineStringIO, self.gcodeStepRepository.xOffset.value, splitLine, self.gcodeStepRepository.xStepLength.value )
self.addCharacterInteger( 'Y', lineStringIO, self.gcodeStepRepository.yOffset.value, splitLine, self.gcodeStepRepository.yStepLength.value )
zString = getCharacterIntegerString( 'Z', self.gcodeStepRepository.zOffset.value, splitLine, self.gcodeStepRepository.zStepLength.value )
feedRateString = getCharacterIntegerString( 'F', 0.0, splitLine, self.gcodeStepRepository.feedRateStepLength.value )
if zString != None:
if zString != self.oldZString or self.gcodeStepRepository.addZEvenWhenUnchanging.value:
self.addStringToLine( lineStringIO, zString )
if feedRateString != None:
if feedRateString != self.oldFeedRateString or self.gcodeStepRepository.addFeedRateEvenWhenUnchanging.value:
self.addStringToLine( lineStringIO, feedRateString )
self.addLine( lineStringIO.getvalue() )
self.oldFeedRateString = feedRateString
self.oldZString = zString
示例7: parseLine
def parseLine( self, line ):
"Parse a gcode line and add it to the statistics."
self.characters += len( line )
self.numberOfLines += 1
splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
if len( splitLine ) < 1:
return
firstWord = splitLine[ 0 ]
if firstWord == 'G1':
self.linearMove( splitLine )
elif firstWord == 'G2':
self.helicalMove( False, splitLine )
elif firstWord == 'G3':
self.helicalMove( True, splitLine )
elif firstWord == 'M101':
self.extruderSet( True )
elif firstWord == 'M102':
self.extruderSet( False )
elif firstWord == 'M103':
self.extruderSet( False )
elif firstWord == 'M108':
self.extruderSpeed = gcodec.getDoubleAfterFirstLetter( splitLine[ 1 ] )
elif firstWord == '(<layerThickness>':
self.layerThickness = float( splitLine[ 1 ] )
self.extrusionDiameter = self.repository.extrusionDiameterOverThickness.value * self.layerThickness
elif firstWord == '(<operatingFeedRatePerSecond>':
self.operatingFeedRatePerSecond = float( splitLine[ 1 ] )
elif firstWord == '(<perimeterWidth>':
self.absolutePerimeterWidth = abs( float( splitLine[ 1 ] ) )
elif firstWord == '(<procedureDone>':
self.procedures.append( splitLine[ 1 ] )
elif firstWord == '(<version>':
self.version = splitLine[ 1 ]
示例8: getHopLine
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
示例9: parseBoundaries
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( 2 ) )
elif firstWord == '(<layer>':
boundaryLayer = euclidean.LoopLayer( float( splitLine[ 1 ] ) )
self.boundaryLayers.append( boundaryLayer )
elif firstWord == '(</extrusion>)':
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()
示例10: getNext
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."
示例11: parseLine
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( 2 ), location.dropAxis( 2 ), self.aroundPixelTable, None, self.aroundWidth )
self.oldLocation = location
elif firstWord == 'M101':
self.isExtruderActive = True
elif firstWord == 'M103':
self.isExtruderActive = False
elif firstWord == '(<layer>':
self.aroundPixelTable = {}
self.average.reset()
elif firstWord == '(</layer>)':
if len( self.boundaryLayers ) > self.layerIndex:
self.addMillThreads()
self.layerIndex += 1
self.distanceFeedRate.addLine( line )
示例12: parseLine
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' )
# print( 'xInteger' )
# print( xInteger )
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 )
示例13: getRelativeStretch
def getRelativeStretch( self, locationComplex, lineIterator ):
"Get relative stretch for a location."
lastLocationComplex = locationComplex
oldTotalLength = 0.0
pointComplex = locationComplex
totalLength = 0.0
while 1:
try:
line = lineIterator.getNext()
except StopIteration:
locationMinusPoint = locationComplex - pointComplex
locationMinusPointLength = abs( locationMinusPoint )
if locationMinusPointLength > 0.0:
return locationMinusPoint / locationMinusPointLength
return complex()
splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
firstWord = splitLine[ 0 ]
pointComplex = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ).dropAxis( 2 )
locationMinusPoint = lastLocationComplex - pointComplex
locationMinusPointLength = abs( locationMinusPoint )
totalLength += locationMinusPointLength
if totalLength >= self.stretchFromDistance:
distanceFromRatio = ( self.stretchFromDistance - oldTotalLength ) / locationMinusPointLength
totalPoint = distanceFromRatio * pointComplex + ( 1.0 - distanceFromRatio ) * lastLocationComplex
locationMinusTotalPoint = locationComplex - totalPoint
return locationMinusTotalPoint / self.stretchFromDistance
lastLocationComplex = pointComplex
oldTotalLength = totalLength
示例14: parseSurroundingLoop
def parseSurroundingLoop( self, line ):
"Parse a surrounding loop."
splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
if len( splitLine ) < 1:
return
firstWord = splitLine[ 0 ]
if firstWord == 'G1':
self.linearMove( splitLine )
if firstWord == 'M101':
self.extruderActive = True
elif firstWord == 'M103':
self.extruderActive = False
elif firstWord == '(<boundaryPoint>':
location = gcodec.getLocationFromSplitLine( None, splitLine )
if self.boundary == None:
self.boundary = []
self.boundary.append( location.dropAxis( 2 ) )
elif firstWord == '(<layer>':
self.layerZ = float( splitLine[ 1 ] )
self.threadLayer = None
elif firstWord == '(<boundaryPerimeter>)':
self.addThreadLayerIfNone()
elif firstWord == '(</boundaryPerimeter>)':
if self.boundary != None:
self.threadLayer.points.append( getPolygonCenter( self.boundary ) )
self.boundary = None
示例15: parseInitialization
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.speedRepository.addFlowRate.value:
self.distanceFeedRate.addTagBracketedLine(
"operatingFlowRate", self.speedRepository.flowRateSetting.value
)
orbitalFeedRatePerSecond = (
self.feedRatePerSecond * self.speedRepository.orbitalFeedRateOverOperatingFeedRate.value
)
self.distanceFeedRate.addTagBracketedLine("orbitalFeedRatePerSecond", orbitalFeedRatePerSecond)
self.distanceFeedRate.addTagBracketedLine(
"travelFeedRatePerSecond", self.speedRepository.travelFeedRatePerSecond.value
)
self.distanceFeedRate.addLine(line)