def writeOutput(fileName=""): "Carve a GNU Triangulated Surface file." startTime = time.time() print("File " + gcodec.getSummarizedFilename(fileName) + " is being carved.") carveGcode = getCraftedText(fileName) if carveGcode == "": return suffixFilename = gcodec.getFilePathWithUnderscoredBasename(fileName, "_carve.svg") gcodec.writeFileText(suffixFilename, carveGcode) print("The carved file is saved as " + gcodec.getSummarizedFilename(suffixFilename)) print("It took " + str(int(round(time.time() - startTime))) + " seconds to carve the file.") preferences.openWebPage(suffixFilename)
def writeOutput( fileName = '' ): "Carve a GNU Triangulated Surface file." startTime = time.time() print( 'File ' + gcodec.getSummarizedFilename( fileName ) + ' is being carved.' ) carveGcode = getCraftedText( fileName ) if carveGcode == '': return suffixFilename = gcodec.getFilePathWithUnderscoredBasename( fileName, '_carve.svg' ) gcodec.writeFileText( suffixFilename, carveGcode ) print( 'The carved file is saved as ' + gcodec.getSummarizedFilename( suffixFilename ) ) print( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to carve the file.' ) preferences.openWebPage( suffixFilename )
def writeGivenPreferences( fileName, gcodeText, vectorwritePreferences ): "Write scalable vector graphics for a gcode file given the preferences." if gcodeText == '': return '' startTime = time.time() vectorwriteGcode = VectorwriteSkein().getSVG( fileName, gcodeText, vectorwritePreferences ) if vectorwriteGcode == '': return suffixFilename = fileName[ : fileName.rfind( '.' ) ] + '_vectorwrite.svg' suffixDirectoryName = os.path.dirname( suffixFilename ) suffixReplacedBaseName = os.path.basename( suffixFilename ).replace( ' ', '_' ) suffixFilename = os.path.join( suffixDirectoryName, suffixReplacedBaseName ) gcodec.writeFileText( suffixFilename, vectorwriteGcode ) print( 'The vectorwrite file is saved as ' + gcodec.getSummarizedFilename( suffixFilename ) ) print( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to vectorwrite the file.' ) preferences.openWebPage( suffixFilename )
def writeGivenPreferences(fileName, gcodeText, vectorwritePreferences): "Write scalable vector graphics for a gcode file given the preferences." if gcodeText == "": return "" startTime = time.time() vectorwriteGcode = VectorwriteSkein().getSVG(fileName, gcodeText, vectorwritePreferences) if vectorwriteGcode == "": return suffixFilename = fileName[: fileName.rfind(".")] + "_vectorwrite.svg" suffixDirectoryName = os.path.dirname(suffixFilename) suffixReplacedBaseName = os.path.basename(suffixFilename).replace(" ", "_") suffixFilename = os.path.join(suffixDirectoryName, suffixReplacedBaseName) gcodec.writeFileText(suffixFilename, vectorwriteGcode) print("The vectorwrite file is saved as " + gcodec.getSummarizedFilename(suffixFilename)) print("It took " + str(int(round(time.time() - startTime))) + " seconds to vectorwrite the file.") preferences.openWebPage(suffixFilename)
def writeOutput( fileName = '' ): "Chop a GNU Triangulated Surface file. If no fileName is specified, chop the first GNU Triangulated Surface file in this folder." if fileName == '': unmodified = gcodec.getFilesWithFileTypesWithoutWords( interpret.getImportPluginFilenames() ) if len( unmodified ) == 0: print( "There are no carvable files in this folder." ) return fileName = unmodified[ 0 ] startTime = time.time() print( 'File ' + gcodec.getSummarizedFilename( fileName ) + ' is being chopped.' ) chopGcode = getCraftedText( fileName ) if chopGcode == '': return suffixFilename = fileName[ : fileName.rfind( '.' ) ] + '_chop.svg' suffixDirectoryName = os.path.dirname( suffixFilename ) suffixReplacedBaseName = os.path.basename( suffixFilename ).replace( ' ', '_' ) suffixFilename = os.path.join( suffixDirectoryName, suffixReplacedBaseName ) gcodec.writeFileText( suffixFilename, chopGcode ) print( 'The chopped file is saved as ' + gcodec.getSummarizedFilename( suffixFilename ) ) print( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to chop the file.' ) preferences.openWebPage( suffixFilename )