Esempio n. 1
0
def fillFile(filename=''):
    "Fill the slices of a gcode file.  If no filename is specified, fill the first unmodified gcode file in this folder."
    if filename == '':
        unmodified = gcodec.getUnmodifiedGCodeFiles()
        if len(unmodified) == 0:
            print >> sys.stderr, (
                "There are no unmodified gcode files in this folder.")
            return
        filename = unmodified[0]
    startTime = time.time()
    fillPreferences = FillPreferences()
    preferences.readPreferences(fillPreferences)
    print >> sys.stderr, ('File ' + gcodec.getSummarizedFilename(filename) +
                          ' is being filled.')
    gcodeText = gcodec.getFileText(filename)
    if gcodeText == '':
        return
    suffixFilename = filename[:filename.rfind('.')] + '_fill.gcode'
    gcodec.writeFileText(suffixFilename,
                         getFillGcode(gcodeText, fillPreferences))
    print >> sys.stderr, ('The filled file is saved as ' +
                          gcodec.getSummarizedFilename(suffixFilename))
    vectorwrite.writeSkeinforgeVectorFile(suffixFilename)
    print >> sys.stderr, ('It took ' +
                          str(int(round(time.time() - startTime))) +
                          ' seconds to fill the file.')
Esempio n. 2
0
def towerFile(filename=''):
    """Tower a gcode linear move file.  Depending on the preferences, either arcPoint, arcRadius, arcSegment, bevel or do nothing.
	If no filename is specified, tower the first unmodified gcode file in this folder."""
    if filename == '':
        unmodified = gcodec.getUnmodifiedGCodeFiles()
        if len(unmodified) == 0:
            print >> sys.stderr, (
                "There are no unmodified gcode files in this folder.")
            return
        filename = unmodified[0]
    towerPreferences = TowerPreferences()
    preferences.readPreferences(towerPreferences)
    if towerPreferences.maximumTowerHeight.value < 1:
        print >> sys.stderr, (
            'The maximum tower height preference is less than one, so nothing will be done.'
        )
        return
    print >> sys.stderr, ('File ' + gcodec.getSummarizedFilename(filename) +
                          ' is being towered.')
    gcodeText = gcodec.getFileText(filename)
    if gcodeText == '':
        return
    suffixFilename = filename[:filename.rfind('.')] + '_tower.gcode'
    gcodec.writeFileText(suffixFilename,
                         getTowerGcode(gcodeText, towerPreferences))
    print >> sys.stderr, ('The towered file is saved as ' + suffixFilename)
    vectorwrite.writeSkeinforgeVectorFile(suffixFilename)
Esempio n. 3
0
def combFile(filename=''):
    """Comb a gcode linear move file.  Depending on the preferences, either arcPoint, arcRadius, arcSegment, bevel or do nothing.
	If no filename is specified, comb the first unmodified gcode file in this folder."""
    if filename == '':
        unmodified = gcodec.getUnmodifiedGCodeFiles()
        if len(unmodified) == 0:
            print >> sys.stderr, (
                "There are no unmodified gcode files in this folder.")
            return
        filename = unmodified[0]
    combPreferences = CombPreferences()
    preferences.readPreferences(combPreferences)
    if not combPreferences.comb.value:
        print >> sys.stderr, (
            'The preference is to not comb, so nothing will be done.')
        return
    print >> sys.stderr, ('File ' + gcodec.getSummarizedFilename(filename) +
                          ' is being combed.')
    gcodeText = gcodec.getFileText(filename)
    if gcodeText == '':
        return
    suffixFilename = filename[:filename.rfind('.')] + '_comb.gcode'
    gcodec.writeFileText(suffixFilename,
                         getCombGcode(gcodeText, combPreferences))
    print >> sys.stderr, ('The combed file is saved as ' + suffixFilename)
    vectorwrite.writeSkeinforgeVectorFile(suffixFilename)
Esempio n. 4
0
def towerChainFile(filename=''):
    """Tower a gcode linear move file.  Chain tower the gcode if it is not already towered.
	Depending on the preferences, either arcPoint, arcRadius, arcSegment, bevel or do nothing.
	If no filename is specified, tower the first unmodified gcode file in this folder."""
    if filename == '':
        unmodified = gcodec.getGNUGcode()
        if len(unmodified) == 0:
            print >> sys.stderr, (
                "There are no unmodified gcode files in this folder.")
            return
        filename = unmodified[0]
    towerPreferences = TowerPreferences()
    preferences.readPreferences(towerPreferences)
    startTime = time.time()
    print >> sys.stderr, ('File ' + gcodec.getSummarizedFilename(filename) +
                          ' is being chain towered.')
    gcodeText = gcodec.getFileText(filename)
    if gcodeText == '':
        return
    suffixFilename = filename[:filename.rfind('.')] + '_tower.gcode'
    gcodec.writeFileText(suffixFilename,
                         getTowerChainGcode(gcodeText, towerPreferences))
    print >> sys.stderr, ('The towered file is saved as ' +
                          gcodec.getSummarizedFilename(suffixFilename))
    vectorwrite.writeSkeinforgeVectorFile(suffixFilename)
    print >> sys.stderr, ('It took ' +
                          str(int(round(time.time() - startTime))) +
                          ' seconds to tower the file.')
Esempio n. 5
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)
Esempio n. 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 )
Esempio n. 7
0
def statisticFile( filename = '' ):
	"Write statistics for a gcode file.  If no filename is specified, write statistics for the first gcode file in this folder that is not a comment or log file."
	if filename == '':
		unmodified = getUncommentedGcodeFiles()
		if len( unmodified ) == 0:
			print >> sys.stderr, ( "There is no gcode file in this folder that is not a comment or log file." )
			return
		filename = unmodified[ 0 ]
	print >> sys.stderr, ( 'Statistics are being generated for the file ' + filename )
	fileText = gcodec.getFileText( filename )
	gcodec.writeFileMessageEnd( '.txt', filename, getStatisticGcode( fileText ), 'The statistics file is saved as ' )
Esempio n. 8
0
def commentFile( filename = '' ):
	"Comment a gcode file.  If no filename is specified, comment the first gcode file in this folder that is not a comment file."
	if filename == '':
		unmodified = getUncommentedGcodeFiles()
		if len( unmodified ) == 0:
			print >> sys.stderr, ( "There is no gcode file in this folder that is not a comment file." )
			return
		filename = unmodified[ 0 ]
	print >> sys.stderr, ( 'File ' + filename + ' is being commented.' )
	fileText = gcodec.getFileText( filename )
	gcodec.writeFileMessageEnd( '_comment.gcode', filename, getCommentGcode( fileText ), 'The commented file is saved as ' )
Esempio n. 9
0
def arcRadiusFile( filename = '' ):
	"Fillet a gcode linear move file into a helical radius move file.  If no filename is specified, arc radius the first unmodified gcode file in this folder."
	if filename == '':
		unmodified = gcodec.getUnmodifiedGCodeFiles()
		if len( unmodified ) == 0:
			print >> sys.stderr, ( "There are no unmodified gcode files in this folder." )
			return
		filename = unmodified[ 0 ]
	filletPreferences = FilletPreferences()
	preferences.readPreferences( filletPreferences )
	print >> sys.stderr, ( 'File ' + gcodec.getSummarizedFilename( filename ) + ' is being filleted into arc radiuses.' )
	gcodeText = gcodec.getFileText( filename )
	if gcodeText == '':
		return
	gcodec.writeFileMessageSuffix( filename, getArcRadiusGcode( filletPreferences, gcodeText ), 'The arc radius file is saved as ', '_fillet' )
Esempio n. 10
0
def commentFile(filename=''):
    "Comment a gcode file.  If no filename is specified, comment the first gcode file in this folder that is not a comment file."
    if filename == '':
        unmodified = getUncommentedGcodeFiles()
        if len(unmodified) == 0:
            print >> sys.stderr, (
                "There is no gcode file in this folder that is not a comment file."
            )
            return
        filename = unmodified[0]
    print >> sys.stderr, ('File ' + filename + ' is being commented.')
    fileText = gcodec.getFileText(filename)
    gcodec.writeFileMessageEnd('_comment.gcode', filename,
                               getCommentGcode(fileText),
                               'The commented file is saved as ')
Esempio n. 11
0
def statisticFile(filename=''):
    "Write statistics for a gcode file.  If no filename is specified, write statistics for the first gcode file in this folder that is not a comment or log file."
    if filename == '':
        unmodified = getUncommentedGcodeFiles()
        if len(unmodified) == 0:
            print >> sys.stderr, (
                "There is no gcode file in this folder that is not a comment or log file."
            )
            return
        filename = unmodified[0]
    print >> sys.stderr, ('Statistics are being generated for the file ' +
                          filename)
    fileText = gcodec.getFileText(filename)
    gcodec.writeFileMessageEnd('.txt', filename, getStatisticGcode(fileText),
                               'The statistics file is saved as ')
Esempio n. 12
0
def bevelFile( filename = '' ):
	"Bevel a gcode linear move file.  If no filename is specified, bevel the first unmodified gcode file in this folder."
	if filename == '':
		unmodified = gcodec.getUnmodifiedGCodeFiles()
		if len( unmodified ) == 0:
			print >> sys.stderr, ( "There are no unmodified gcode files in this folder." )
			return
		filename = unmodified[ 0 ]
	filletPreferences = FilletPreferences()
	preferences.readPreferences( filletPreferences )
	print >> sys.stderr, ( 'File ' + gcodec.getSummarizedFilename( filename ) + ' is being beveled.' )
	gcodeText = gcodec.getFileText( filename )
	if gcodeText == '':
		return
	gcodec.writeFileMessageSuffix( filename, getBevelGcode( filletPreferences, gcodeText ), 'The beveled file is saved as ', '_fillet' )
Esempio n. 13
0
def writeVectorFile( filename = '' ):
	"Write scalable vector graphics for a gcode file.  If no filename is specified, write scalable vector graphics for the first gcode file in this folder."
	if filename == '':
		unmodified = gcodec.getFilesWithFileTypeWithoutWords( 'gcode' )
		if len( unmodified ) == 0:
			print >> sys.stderr, ( "There is no gcode file in this folder." )
			return
		filename = unmodified[ 0 ]
	vectorwritePreferences = VectorwritePreferences()
	preferences.readPreferences( vectorwritePreferences )
	print >> sys.stderr, ( 'Scalable vector graphics are being generated for the file ' + gcodec.getSummarizedFilename( filename ) )
	fileText = gcodec.getFileText( filename )
	suffixFilename = filename[ : filename.rfind( '.' ) ] + '.svg'
	suffixFilename = suffixFilename.replace( ' ', '_' )
	gcodec.writeFileText( suffixFilename, getVectorGcode( fileText, vectorwritePreferences ) )
	print >> sys.stderr, ( 'The scalable vector graphics file is saved as ' + gcodec.getSummarizedFilename( suffixFilename ) )
Esempio n. 14
0
def arcRadiusFile(filename=''):
    "Fillet a gcode linear move file into a helical radius move file.  If no filename is specified, arc radius the first unmodified gcode file in this folder."
    if filename == '':
        unmodified = gcodec.getUnmodifiedGCodeFiles()
        if len(unmodified) == 0:
            print >> sys.stderr, (
                "There are no unmodified gcode files in this folder.")
            return
        filename = unmodified[0]
    filletPreferences = FilletPreferences()
    preferences.readPreferences(filletPreferences)
    print >> sys.stderr, ('File ' + gcodec.getSummarizedFilename(filename) +
                          ' is being filleted into arc radiuses.')
    gcodeText = gcodec.getFileText(filename)
    if gcodeText == '':
        return
    gcodec.writeFileMessageSuffix(
        filename, getArcRadiusGcode(filletPreferences, gcodeText),
        'The arc radius file is saved as ', '_fillet')
Esempio n. 15
0
def bevelFile(filename=''):
    "Bevel a gcode linear move file.  If no filename is specified, bevel the first unmodified gcode file in this folder."
    if filename == '':
        unmodified = gcodec.getUnmodifiedGCodeFiles()
        if len(unmodified) == 0:
            print >> sys.stderr, (
                "There are no unmodified gcode files in this folder.")
            return
        filename = unmodified[0]
    filletPreferences = FilletPreferences()
    preferences.readPreferences(filletPreferences)
    print >> sys.stderr, ('File ' + gcodec.getSummarizedFilename(filename) +
                          ' is being beveled.')
    gcodeText = gcodec.getFileText(filename)
    if gcodeText == '':
        return
    gcodec.writeFileMessageSuffix(filename,
                                  getBevelGcode(filletPreferences, gcodeText),
                                  'The beveled file is saved as ', '_fillet')
Esempio n. 16
0
def stretchFile( filename = '' ):
	"""Stretch a gcode linear move file.  Depending on the preferences, either arcPoint, arcRadius, arcSegment, bevel or do nothing.
	If no filename is specified, stretch the first unmodified gcode file in this folder."""
	if filename == '':
		unmodified = gcodec.getUnmodifiedGCodeFiles()
		if len( unmodified ) == 0:
			print >> sys.stderr, ( "There are no unmodified gcode files in this folder." )
			return
		filename = unmodified[ 0 ]
	stretchPreferences = StretchPreferences()
	preferences.readPreferences( stretchPreferences )
	print >> sys.stderr, ( 'File ' + gcodec.getSummarizedFilename( filename ) + ' is being stretched.' )
	gcodeText = gcodec.getFileText( filename )
	if gcodeText == '':
		return
	suffixFilename = filename[ : filename.rfind( '.' ) ] + '_stretch.gcode'
	gcodec.writeFileText( suffixFilename, getStretchGcode( gcodeText, stretchPreferences ) )
	print >> sys.stderr, ( 'The stretched file is saved as ' + suffixFilename )
	vectorwrite.writeSkeinforgeVectorFile( suffixFilename )
Esempio n. 17
0
def sliceFile( filename = '' ):
	"Slice a GNU Triangulated Surface file.  If no filename is specified, slice the first GNU Triangulated Surface file in this folder."
	if filename == '':
		unmodified = gcodec.getGNUTriangulatedSurfaceFiles()
		if len( unmodified ) == 0:
			print >> sys.stderr, ( "There are no GNU Triangulated Surface files in this folder." )
			return
		filename = unmodified[ 0 ]
	startTime = time.time()
	slicePreferences = SlicePreferences()
	preferences.readPreferences( slicePreferences )
	print >> sys.stderr, ( 'File ' + gcodec.getSummarizedFilename( filename ) + ' is being sliced.' )
	gnuTriangulatedSurfaceText = gcodec.getFileText( filename )
	if gnuTriangulatedSurfaceText == '':
		return
	suffixFilename = filename[ : filename.rfind( '.' ) ] + '_slice.gcode'
	gcodec.writeFileText( suffixFilename, getSliceGcode( gnuTriangulatedSurfaceText, slicePreferences ) )
	print >> sys.stderr, ( 'The sliced file is saved as ' + gcodec.getSummarizedFilename( suffixFilename ) )
	vectorwrite.writeSkeinforgeVectorFile( suffixFilename )
	print >> sys.stderr, ( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to slice the file.' )
Esempio n. 18
0
def fillFile( filename = '' ):
	"Fill the slices of a gcode file.  If no filename is specified, fill the first unmodified gcode file in this folder."
	if filename == '':
		unmodified = gcodec.getUnmodifiedGCodeFiles()
		if len( unmodified ) == 0:
			print >> sys.stderr, ( "There are no unmodified gcode files in this folder." )
			return
		filename = unmodified[ 0 ]
	startTime = time.time()
	fillPreferences = FillPreferences()
	preferences.readPreferences( fillPreferences )
	print >> sys.stderr, ( 'File ' + gcodec.getSummarizedFilename( filename ) + ' is being filled.' )
	gcodeText = gcodec.getFileText( filename )
	if gcodeText == '':
		return
	suffixFilename = filename[ : filename.rfind( '.' ) ] + '_fill.gcode'
	gcodec.writeFileText( suffixFilename, getFillGcode( gcodeText, fillPreferences ) )
	print >> sys.stderr, ( 'The filled file is saved as ' + gcodec.getSummarizedFilename( suffixFilename ) )
	vectorwrite.writeSkeinforgeVectorFile( suffixFilename )
	print >> sys.stderr, ( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to fill the file.' )
Esempio n. 19
0
def towerFile( filename = '' ):
	"""Tower a gcode linear move file.  Depending on the preferences, either arcPoint, arcRadius, arcSegment, bevel or do nothing.
	If no filename is specified, tower the first unmodified gcode file in this folder."""
	if filename == '':
		unmodified = gcodec.getUnmodifiedGCodeFiles()
		if len( unmodified ) == 0:
			print >> sys.stderr, ( "There are no unmodified gcode files in this folder." )
			return
		filename = unmodified[ 0 ]
	towerPreferences = TowerPreferences()
	preferences.readPreferences( towerPreferences )
	if towerPreferences.maximumTowerHeight.value < 1:
		print >> sys.stderr, ( 'The maximum tower height preference is less than one, so nothing will be done.' )
		return
	print >> sys.stderr, ( 'File ' + gcodec.getSummarizedFilename( filename ) + ' is being towered.' )
	gcodeText = gcodec.getFileText( filename )
	if gcodeText == '':
		return
	suffixFilename = filename[ : filename.rfind( '.' ) ] + '_tower.gcode'
	gcodec.writeFileText( suffixFilename, getTowerGcode( gcodeText, towerPreferences ) )
	print >> sys.stderr, ( 'The towered file is saved as ' + suffixFilename )
	vectorwrite.writeSkeinforgeVectorFile( suffixFilename )
Esempio n. 20
0
def stretchFile(filename=''):
    """Stretch a gcode linear move file.  Depending on the preferences, either arcPoint, arcRadius, arcSegment, bevel or do nothing.
	If no filename is specified, stretch the first unmodified gcode file in this folder."""
    if filename == '':
        unmodified = gcodec.getUnmodifiedGCodeFiles()
        if len(unmodified) == 0:
            print >> sys.stderr, (
                "There are no unmodified gcode files in this folder.")
            return
        filename = unmodified[0]
    stretchPreferences = StretchPreferences()
    preferences.readPreferences(stretchPreferences)
    print >> sys.stderr, ('File ' + gcodec.getSummarizedFilename(filename) +
                          ' is being stretched.')
    gcodeText = gcodec.getFileText(filename)
    if gcodeText == '':
        return
    suffixFilename = filename[:filename.rfind('.')] + '_stretch.gcode'
    gcodec.writeFileText(suffixFilename,
                         getStretchGcode(gcodeText, stretchPreferences))
    print >> sys.stderr, ('The stretched file is saved as ' + suffixFilename)
    vectorwrite.writeSkeinforgeVectorFile(suffixFilename)
Esempio n. 21
0
def combFile( filename = '' ):
	"""Comb a gcode linear move file.  Depending on the preferences, either arcPoint, arcRadius, arcSegment, bevel or do nothing.
	If no filename is specified, comb the first unmodified gcode file in this folder."""
	if filename == '':
		unmodified = gcodec.getUnmodifiedGCodeFiles()
		if len( unmodified ) == 0:
			print >> sys.stderr, ( "There are no unmodified gcode files in this folder." )
			return
		filename = unmodified[ 0 ]
	combPreferences = CombPreferences()
	preferences.readPreferences( combPreferences )
	if not combPreferences.comb.value:
		print >> sys.stderr, ( 'The preference is to not comb, so nothing will be done.' )
		return
	print >> sys.stderr, ( 'File ' + gcodec.getSummarizedFilename( filename ) + ' is being combed.' )
	gcodeText = gcodec.getFileText( filename )
	if gcodeText == '':
		return
	suffixFilename = filename[ : filename.rfind( '.' ) ] + '_comb.gcode'
	gcodec.writeFileText( suffixFilename, getCombGcode( gcodeText, combPreferences ) )
	print >> sys.stderr, ( 'The combed file is saved as ' + suffixFilename )
	vectorwrite.writeSkeinforgeVectorFile( suffixFilename )
Esempio n. 22
0
def combChainFile( filename = '' ):
	"""Comb a gcode linear move file.  Chain comb the gcode if it is not already combed.
	Depending on the preferences, either arcPoint, arcRadius, arcSegment, bevel or do nothing.
	If no filename is specified, comb the first unmodified gcode file in this folder."""
	if filename == '':
		unmodified = gcodec.getGNUGcode()
		if len( unmodified ) == 0:
			print >> sys.stderr, ( "There are no unmodified gcode files in this folder." )
			return
		filename = unmodified[ 0 ]
	combPreferences = CombPreferences()
	preferences.readPreferences( combPreferences )
	startTime = time.time()
	print >> sys.stderr, ( 'File ' + gcodec.getSummarizedFilename( filename ) + ' is being chain combed.' )
	gcodeText = gcodec.getFileText( filename )
	if gcodeText == '':
		return
	suffixFilename = filename[ : filename.rfind( '.' ) ] + '_comb.gcode'
	gcodec.writeFileText( suffixFilename, getCombChainGcode( gcodeText, combPreferences ) )
	print >> sys.stderr, ( 'The combed file is saved as ' + gcodec.getSummarizedFilename( suffixFilename ) )
	vectorwrite.writeSkeinforgeVectorFile( suffixFilename )
	print >> sys.stderr, ( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to comb the file.' )
Esempio n. 23
0
def displayFile( filename ):
	"Parse a gcode file and display the commands."
	print >> sys.stderr, ( 'File ' + filename + ' is being displayed.' )
	fileText = gcodec.getFileText( filename )
	gcodec.writeFileMessageSuffix( filename, displayText( fileText ), 'The gcode log file is saved as ', '_log' )
Esempio n. 24
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 )
Esempio n. 25
0
def extrudeFile( filename ):
	"""Parse a gcode file and send the commands to the extruder.
	This function requires write access to the serial device, running as root is one way to get that access."""
	print >> sys.stderr, ( 'File ' + filename + ' is being extruded.' )
	fileText = gcodec.getFileText( filename )
	gcodec.writeFileMessageSuffix( filename, extrudeText( fileText ), 'The gcode log file is saved as ', '_log' )