示例#1
0
 def parseGcode(self, filletPreferences, gcodeText):
     "Parse gcode text and store the bevel gcode."
     self.lines = gcodec.getTextLines(gcodeText)
     self.parseInitialization(filletPreferences)
     for self.lineIndex in range(self.lineIndex, len(self.lines)):
         line = self.lines[self.lineIndex]
         self.parseLine(line)
示例#2
0
	def parseGcode( self, filletPreferences, gcodeText ):
		"Parse gcode text and store the bevel gcode."
		self.lines = gcodec.getTextLines( gcodeText )
		self.parseInitialization( filletPreferences )
		for self.lineIndex in range( self.lineIndex, len( self.lines ) ):
			line = self.lines[ self.lineIndex ]
			self.parseLine( line )
示例#3
0
	def getFromGNUTriangulatedSurfaceText( self, gnuTriangulatedSurfaceText ):
		"Initialize from gnuTriangulatedSurfaceText."
		lines = gcodec.getTextLines( gnuTriangulatedSurfaceText )
		linesWithoutComments = []
		for line in lines:
			if len( line ) > 0:
				firstCharacter = line[ 0 ]
				if firstCharacter != '#' and firstCharacter != '!':
					linesWithoutComments.append( line )
		splitLine = linesWithoutComments[ 0 ].split( " " )
		numberOfVertices = int( splitLine[ 0 ] )
		numberOfEdges = int( splitLine[ 1 ] )
		numberOfFaces = int( splitLine[ 2 ] )
		faceTriples = []
		for vertexIndex in range( numberOfVertices ):
			line = linesWithoutComments[ vertexIndex + 1 ]
			splitLine = line.split( " " )
			vertex = Vec3().getFromXYZ( float( splitLine[ 0 ] ), float( splitLine[ 1 ] ), float( splitLine[ 2 ] ) )
			self.vertices.append( vertex )
		edgeStart = numberOfVertices + 1
		for edgeIndex in range( numberOfEdges ):
			line = linesWithoutComments[ edgeIndex + edgeStart ]
			splitLine = line.split( " " )
			edge = Edge().getFromVertexIndices( edgeIndex, int( splitLine[ 0 ] ) - 1, int( splitLine[ 1 ] ) - 1 )
			self.edges.append( edge )
		faceStart = edgeStart + numberOfEdges
		for faceIndex in range( numberOfFaces ):
			line = linesWithoutComments[ faceIndex + faceStart ]
			splitLine = line.split( " " )
			edgeIndexFirst = int( splitLine[ 0 ] ) - 1
			edgeIndexSecond = int( splitLine[ 1 ] ) - 1
			edgeIndexThird = int( splitLine[ 2 ] ) - 1
			face = Face().getFromEdgeIndices( self.edges, faceIndex, edgeIndexFirst, edgeIndexSecond, edgeIndexThird )
			self.faces.append( face )
		return self
示例#4
0
	def parseGcode( self, gcodeText, stretchPreferences ):
		"Parse gcode text and store the stretch gcode."
		self.lines = gcodec.getTextLines( gcodeText )
		self.layerIndex = - 1
		self.stretchPreferences = stretchPreferences
		for self.lineIndex in range( len( self.lines ) ):
			line = self.lines[ self.lineIndex ]
			self.parseStretch( line )
示例#5
0
 def parseGcode(self, gcodeText, stretchPreferences):
     "Parse gcode text and store the stretch gcode."
     self.lines = gcodec.getTextLines(gcodeText)
     self.layerIndex = -1
     self.stretchPreferences = stretchPreferences
     for self.lineIndex in range(len(self.lines)):
         line = self.lines[self.lineIndex]
         self.parseStretch(line)
示例#6
0
def readPreferences( preferences ):
	"Set an archive to the preferences read from a file."
	preferencesText = gcodec.getFileText( preferences.filenamePreferences )
	lines = gcodec.getTextLines( preferencesText )
	preferenceTable = {}
	for preference in preferences.archive:
		preferenceTable[ preference.name ] = preference
	for lineIndex in range( len( lines ) ):
		setArchiveToLine( lineIndex, lines, preferenceTable )
示例#7
0
def readPreferences(preferences):
    "Set an archive to the preferences read from a file."
    preferencesText = gcodec.getFileText(preferences.filenamePreferences)
    lines = gcodec.getTextLines(preferencesText)
    preferenceTable = {}
    for preference in preferences.archive:
        preferenceTable[preference.name] = preference
    for lineIndex in range(len(lines)):
        setArchiveToLine(lineIndex, lines, preferenceTable)
示例#8
0
 def parseGcode(self, gcodeText):
     "Parse gcode text and store the comb gcode."
     self.lines = gcodec.getTextLines(gcodeText)
     for line in self.lines:
         self.parseLine(line)
     self.oldLocation = None
     for lineIndex in range(len(self.lines)):
         line = self.lines[lineIndex]
         self.parseAddTravel(line)
示例#9
0
	def parseGcode( self, gcodeText ):
		"Parse gcode text and store the comb gcode."
		self.lines = gcodec.getTextLines( gcodeText )
		for line in self.lines:
			self.parseLine( line )
		self.oldLocation = None
		for lineIndex in range( len( self.lines ) ):
			line = self.lines[ lineIndex ]
			self.parseAddTravel( line )
示例#10
0
	def parseGcode( self, gcodeText ):
		"Parse gcode text and store the commented gcode."
		self.characters = 0
		self.cornerHigh = Vec3( - 999999999.0, - 999999999.0, - 999999999.0 )
		self.cornerLow = Vec3( 999999999.0, 999999999.0, 999999999.0 )
		self.extruderActive = False
		self.extruderSpeed = 0.0
		self.extruderToggled = 0
		self.extrusionDiameter = 0.5
		self.extrusionWidth = 0.4
		self.feedrateMinute = 600.0
		self.layerThickness = 0.4
		self.numberOfLines = 0
		self.procedures = []
		self.totalBuildTime = 0.0
		self.totalDistanceExtruded = 0.0
		self.totalDistanceTraveled = 0.0
		lines = gcodec.getTextLines( gcodeText )
		for line in lines:
			self.parseLine( line )
		averageFeedrate = self.totalDistanceTraveled / self.totalBuildTime
		self.characters += self.numberOfLines
		kilobytes = round( self.characters / 1024.0 )
		halfExtrusionWidth = 0.5 * self.extrusionWidth
		halfExtrusionCorner = Vec3( halfExtrusionWidth, halfExtrusionWidth, halfExtrusionWidth )
		self.cornerHigh.add( halfExtrusionCorner )
		self.cornerLow.subtract( halfExtrusionCorner )
		extent = self.cornerHigh.minus( self.cornerLow )
		roundedHigh = euclidean.getRoundedPoint( self.cornerHigh )
		roundedLow = euclidean.getRoundedPoint( self.cornerLow )
		roundedExtent = euclidean.getRoundedPoint( extent )
		axisString =  " axis, the extrusion starts at "
		volumeExtruded = 0.0009 * self.extrusionWidth * self.layerThickness * self.totalDistanceExtruded # the 9 comes from a typical fill density of 0.9
		self.addLine( "On the X" + axisString + str( int ( roundedLow.x ) ) + " mm and ends at " + str( int ( roundedHigh.x ) ) + " mm, for a width of " + str( int ( extent.x ) ) + " mm" )
		self.addLine( "On the Y" + axisString + str( int ( roundedLow.y ) ) + " mm and ends at " + str( int ( roundedHigh.y ) ) + " mm, for a depth of " + str( int ( extent.y ) ) + " mm" )
		self.addLine( "On the Z" + axisString + str( int ( roundedLow.z ) ) + " mm and ends at " + str( int ( roundedHigh.z ) ) + " mm, for a height of " + str( int ( extent.z ) ) + " mm" )
		self.addLine( "The average feedrate is "  + str( int( round( averageFeedrate ) ) )  + " mm/s, (" + str( int( round( 60.0 * averageFeedrate ) ) ) + " mm/min)." )
		self.addLine( "The extruder speed is " + str( int( round( self.extruderSpeed ) ) ) )
		self.addLine( "The extruder was extruding "  + str( int( round( 100.0 * self.totalDistanceExtruded / self.totalDistanceTraveled ) ) ) + "% of the time." )
		self.addLine( "The extruder was toggled " + str( self.extruderToggled ) + " times." )
		self.addLine( "The extrusion diameter is "  + str( self.extrusionDiameter ) + " mm." )
		self.addLine( "The extrusion width is "  + str( self.extrusionWidth ) + " mm." )
		self.addLine( "The following procedures have been performed on the skein:" )
		for procedure in self.procedures:
			self.addLine( procedure )
		self.addLine( "The layer thickness is "  + str( self.layerThickness ) + " mm." )
		self.addLine( "The text has " + str( self.numberOfLines ) + " lines and a size of " + str( kilobytes ) + " KB." )
		self.addLine( "The total build time is " + str( int( round( self.totalBuildTime ) ) ) + " s." )
		self.addLine( "The total distance extruded is " + str( int( round( self.totalDistanceExtruded ) ) ) + " mm." )
		self.addLine( "The total distance traveled is " + str( int( round( self.totalDistanceTraveled ) ) ) + " mm." )
		self.addLine( "The volume extruded is "  + str( int( round( volumeExtruded ) ) ) + " cc." )
		print >> sys.stderr, ( '' )
		print >> sys.stderr, ( self.output.getvalue() )
		print >> sys.stderr, ( '' )
示例#11
0
	def parseGcode( self, gcodeText, towerPreferences ):
		"Parse gcode text and store the tower gcode."
		self.lines = gcodec.getTextLines( gcodeText )
		self.towerPreferences = towerPreferences
		self.parseInitialization()
		self.oldLocation = None
		for lineIndex in range( self.lineIndex, len( self.lines ) ):
			self.parseLine( lineIndex )
		for threadLayer in self.threadLayers:
			self.addIslandLayer( threadLayer )
		for self.layerIndex in range( min( len( self.islandLayers ), towerPreferences.towerStartLayer.value ) ):
			self.addEntireLayer( self.layerIndex )
		self.addTowers()
		self.addShutdownToOutput()
示例#12
0
	def parseGcode( self, fillPreferences, gcodeText ):
		"Parse gcode text and store the bevel gcode."
		self.fillPreferences = fillPreferences
		self.lines = gcodec.getTextLines( gcodeText )
		self.parseInitialization()
		self.feedratePerMinute = 60.0 * fillPreferences.feedratePerSecond.value
		self.fillDensity = fillPreferences.fillDensity.value
		self.fillBeginRotation = math.radians( fillPreferences.fillBeginRotation.value )
		self.fillOddLayerExtraRotation = math.radians( fillPreferences.fillOddLayerExtraRotation.value )
		self.solidSurfaceThickness = int( round( self.fillPreferences.solidSurfaceThickness.value ) )
		self.doubleSolidSurfaceThickness = self.solidSurfaceThickness + self.solidSurfaceThickness
		for lineIndex in range( self.lineIndex, len( self.lines ) ):
			self.parseLine( lineIndex )
		for layerIndex in range( len( self.rotatedLayers ) ):
			self.addFill( layerIndex )
		self.addShutdownToOutput()
示例#13
0
 def parseGcode(self, gcodeText, towerPreferences):
     "Parse gcode text and store the tower gcode."
     self.lines = gcodec.getTextLines(gcodeText)
     self.towerPreferences = towerPreferences
     self.parseInitialization()
     self.oldLocation = None
     for lineIndex in range(self.lineIndex, len(self.lines)):
         self.parseLine(lineIndex)
     for threadLayer in self.threadLayers:
         self.addIslandLayer(threadLayer)
     for self.layerIndex in range(
             min(len(self.islandLayers),
                 towerPreferences.towerStartLayer.value)):
         self.addEntireLayer(self.layerIndex)
     self.addTowers()
     self.addShutdownToOutput()
示例#14
0
 def parseGcode(self, fillPreferences, gcodeText):
     "Parse gcode text and store the bevel gcode."
     self.fillPreferences = fillPreferences
     self.lines = gcodec.getTextLines(gcodeText)
     self.parseInitialization()
     self.feedratePerMinute = 60.0 * fillPreferences.feedratePerSecond.value
     self.fillDensity = fillPreferences.fillDensity.value
     self.fillBeginRotation = math.radians(
         fillPreferences.fillBeginRotation.value)
     self.fillOddLayerExtraRotation = math.radians(
         fillPreferences.fillOddLayerExtraRotation.value)
     self.solidSurfaceThickness = int(
         round(self.fillPreferences.solidSurfaceThickness.value))
     self.doubleSolidSurfaceThickness = self.solidSurfaceThickness + self.solidSurfaceThickness
     for lineIndex in range(self.lineIndex, len(self.lines)):
         self.parseLine(lineIndex)
     for layerIndex in range(len(self.rotatedLayers)):
         self.addFill(layerIndex)
     self.addShutdownToOutput()
示例#15
0
	def parseGcode( self, gcodeText, vectorwritePreferences ):
		"Parse gcode text and store the commented gcode."
		self.initializeActiveLocation()
		self.cornerHigh = Vec3( - 999999999.0, - 999999999.0, - 999999999.0 )
		self.cornerLow = Vec3( 999999999.0, 999999999.0, 999999999.0 )
		lines = gcodec.getTextLines( gcodeText )
		for line in lines:
			self.parseCorner( line )
		self.initializeActiveLocation()
		self.colorNames = [ 'brown', 'red', 'orange', 'yellow', 'green', 'blue', 'purple' ]
		self.scale = vectorwritePreferences.pixelsWidthExtrusion.value / self.extrusionWidth
		self.vectorWindow = VectorWindow()
		self.vectorWindow.setPaneCorners( self.scale * self.cornerLow.dropAxis( 2 ), self.scale * self.cornerHigh.dropAxis( 2 ) )
		for lineIndex in range( len( lines ) ):
			line = lines[ lineIndex ]
			nextLine = ''
			nextIndex = lineIndex + 1
			if nextIndex < len( lines ):
				nextLine = lines[ nextIndex ]
			self.parseLine( line, nextLine )
示例#16
0
 def parseGcode(self, gcodeText):
     "Parse gcode text and store the commented gcode."
     lines = gcodec.getTextLines(gcodeText)
     for line in lines:
         self.parseLine(line)
     print >> sys.stderr, (self.output.getvalue())
示例#17
0
	def addFromFile( self, filename ):
		"Add lines of text from the filename."
		fileLines = gcodec.getTextLines( gcodec.getFileText( filename ) )
		for line in fileLines:
			self.addLine( line )
示例#18
0
	def parseGcode( self, gcodeText ):
		"Parse gcode text and store the commented gcode."
		lines = gcodec.getTextLines( gcodeText )
		for line in lines:
			self.parseLine( line )
		print >> sys.stderr, ( self.output.getvalue() )
示例#19
0
 def parseGcode(self, gcodeText):
     "Parse gcode text and store the commented gcode."
     self.characters = 0
     self.cornerHigh = Vec3(-999999999.0, -999999999.0, -999999999.0)
     self.cornerLow = Vec3(999999999.0, 999999999.0, 999999999.0)
     self.extruderActive = False
     self.extruderSpeed = 0.0
     self.extruderToggled = 0
     self.extrusionDiameter = 0.5
     self.extrusionWidth = 0.4
     self.feedrateMinute = 600.0
     self.layerThickness = 0.4
     self.numberOfLines = 0
     self.procedures = []
     self.totalBuildTime = 0.0
     self.totalDistanceExtruded = 0.0
     self.totalDistanceTraveled = 0.0
     lines = gcodec.getTextLines(gcodeText)
     for line in lines:
         self.parseLine(line)
     averageFeedrate = self.totalDistanceTraveled / self.totalBuildTime
     self.characters += self.numberOfLines
     kilobytes = round(self.characters / 1024.0)
     halfExtrusionWidth = 0.5 * self.extrusionWidth
     halfExtrusionCorner = Vec3(halfExtrusionWidth, halfExtrusionWidth,
                                halfExtrusionWidth)
     self.cornerHigh.add(halfExtrusionCorner)
     self.cornerLow.subtract(halfExtrusionCorner)
     extent = self.cornerHigh.minus(self.cornerLow)
     roundedHigh = euclidean.getRoundedPoint(self.cornerHigh)
     roundedLow = euclidean.getRoundedPoint(self.cornerLow)
     roundedExtent = euclidean.getRoundedPoint(extent)
     axisString = " axis, the extrusion starts at "
     volumeExtruded = 0.0009 * self.extrusionWidth * self.layerThickness * self.totalDistanceExtruded  # the 9 comes from a typical fill density of 0.9
     self.addLine("On the X" + axisString + str(int(roundedLow.x)) +
                  " mm and ends at " + str(int(roundedHigh.x)) +
                  " mm, for a width of " + str(int(extent.x)) + " mm")
     self.addLine("On the Y" + axisString + str(int(roundedLow.y)) +
                  " mm and ends at " + str(int(roundedHigh.y)) +
                  " mm, for a depth of " + str(int(extent.y)) + " mm")
     self.addLine("On the Z" + axisString + str(int(roundedLow.z)) +
                  " mm and ends at " + str(int(roundedHigh.z)) +
                  " mm, for a height of " + str(int(extent.z)) + " mm")
     self.addLine("The average feedrate is " +
                  str(int(round(averageFeedrate))) + " mm/s, (" +
                  str(int(round(60.0 * averageFeedrate))) + " mm/min).")
     self.addLine("The extruder speed is " +
                  str(int(round(self.extruderSpeed))))
     self.addLine("The extruder was extruding " + str(
         int(
             round(100.0 * self.totalDistanceExtruded /
                   self.totalDistanceTraveled))) + "% of the time.")
     self.addLine("The extruder was toggled " + str(self.extruderToggled) +
                  " times.")
     self.addLine("The extrusion diameter is " +
                  str(self.extrusionDiameter) + " mm.")
     self.addLine("The extrusion width is " + str(self.extrusionWidth) +
                  " mm.")
     self.addLine(
         "The following procedures have been performed on the skein:")
     for procedure in self.procedures:
         self.addLine(procedure)
     self.addLine("The layer thickness is " + str(self.layerThickness) +
                  " mm.")
     self.addLine("The text has " + str(self.numberOfLines) +
                  " lines and a size of " + str(kilobytes) + " KB.")
     self.addLine("The total build time is " +
                  str(int(round(self.totalBuildTime))) + " s.")
     self.addLine("The total distance extruded is " +
                  str(int(round(self.totalDistanceExtruded))) + " mm.")
     self.addLine("The total distance traveled is " +
                  str(int(round(self.totalDistanceTraveled))) + " mm.")
     self.addLine("The volume extruded is " +
                  str(int(round(volumeExtruded))) + " cc.")
     print >> sys.stderr, ('')
     print >> sys.stderr, (self.output.getvalue())
     print >> sys.stderr, ('')