def writeOutput(fileName=""): "Export a gcode linear move file." fileName = interpret.getFirstTranslatorFileNameUnmodified(fileName) if fileName == "": return exportPreferences = ExportPreferences() preferences.getReadPreferences(exportPreferences) startTime = time.time() print("File " + gcodec.getSummarizedFilename(fileName) + " is being chain exported.") suffixFilename = fileName[: fileName.rfind(".")] + "_export." + exportPreferences.fileExtension.value gcodeText = gcodec.getGcodeFileText(fileName, "") procedures = consecution.getProcedures("export", gcodeText) gcodeText = consecution.getChainTextFromProcedures(fileName, procedures[:-1], gcodeText) if gcodeText == "": return analyze.writeOutput(suffixFilename, gcodeText) exportChainGcode = getCraftedTextFromText(gcodeText, exportPreferences) replacableExportChainGcode = None selectedPluginModule = getSelectedPluginModule(exportPreferences.exportPlugins) if selectedPluginModule == None: replacableExportChainGcode = exportChainGcode else: if selectedPluginModule.isReplacable(): replacableExportChainGcode = selectedPluginModule.getOutput(exportChainGcode) else: selectedPluginModule.writeOutput(suffixFilename, exportChainGcode) if replacableExportChainGcode != None: replacableExportChainGcode = getReplaced(replacableExportChainGcode) gcodec.writeFileText(suffixFilename, replacableExportChainGcode) print("The exported file is saved as " + gcodec.getSummarizedFilename(suffixFilename)) if exportPreferences.alsoSendOutputTo.value != "": if replacableExportChainGcode == None: replacableExportChainGcode = selectedPluginModule.getOutput(exportChainGcode) exec("print >> " + exportPreferences.alsoSendOutputTo.value + ", replacableExportChainGcode") print("It took " + str(int(round(time.time() - startTime))) + " seconds to export the file.")
def writeOutput(fileName=''): "Carve a GNU Triangulated Surface file. If no fileName is specified, carve the first GNU Triangulated Surface file in this folder." if fileName == '': unmodified = gcodec.getFilesWithFileTypesWithoutWords( interpret.getImportPluginFilenames()) if len(unmodified) == 0: print( "There are no GNU Triangulated Surface files in this folder.") return fileName = unmodified[0] startTime = time.time() carvePreferences = CarvePreferences() preferences.readPreferences(carvePreferences) print('File ' + gcodec.getSummarizedFilename(fileName) + ' is being carved.') carveGcode = getCarveGcode(fileName, carvePreferences) if carveGcode == '': return suffixFilename = fileName[:fileName.rfind('.')] + '_carve.svg' suffixFilename = suffixFilename.replace(' ', '_') gcodec.writeFileText(suffixFilename, carveGcode) print('The carved file is saved as ' + gcodec.getSummarizedFilename(suffixFilename)) # packageFilePath = os.path.abspath( __file__ ) # for level in xrange( numberOfLevelsDeepInPackageHierarchy + 1 ): # packageFilePath = os.path.dirname( packageFilePath ) # documentationPath = os.path.join( os.path.join( packageFilePath, 'documentation' ), self.displayPreferences.fileNameHelp ) # os.system( webbrowser.get().name + ' ' + documentationPath )#used this instead of webbrowser.open() to workaround webbrowser open() bug # analyze.writeOutput( suffixFilename, carveGcode ) os.system( webbrowser.get().name + ' ' + suffixFilename ) #used this instead of webbrowser.open() to workaround webbrowser open() bug print('It took ' + str(int(round(time.time() - startTime))) + ' seconds to carve the file.')
def writeOutput(fileName=''): print("raftless - writeOutput") "Raftless a gcode linear move file. Chain raftless the gcode if it is not already raftless'd. If no fileName is specified, raftless the first unmodified gcode file in this folder." if fileName == '': unmodified = interpret.getGNUTranslatorFilesUnmodified() if len(unmodified) == 0: print("There are no unmodified gcode files in this folder.") return fileName = unmodified[0] raftlessPreferences = RaftlessPreferences() preferences.readPreferences(raftlessPreferences) print() startTime = time.time() print("File " + gcodec.getSummarizedFilename(fileName) + " is being chain raftless'd.") suffixFilename = fileName[:fileName.rfind('.')] + '_raftless.gcode' raftlessGcode = getRaftlessChainGcode(fileName, '', raftlessPreferences) if raftlessGcode == '': return gcodec.writeFileText(suffixFilename, raftlessGcode) print('The raftless file is saved as ' + gcodec.getSummarizedFilename(suffixFilename)) analyze.writeOutput(suffixFilename, raftlessGcode) print('It took ' + str(int(round(time.time() - startTime))) + ' seconds to raftless the file.')
def writeOutput(fileName=""): "Carve a GNU Triangulated Surface file. If no fileName is specified, carve the first GNU Triangulated Surface file in this folder." if fileName == "": unmodified = gcodec.getFilesWithFileTypesWithoutWords(interpret.getImportPluginFilenames()) if len(unmodified) == 0: print("There are no GNU Triangulated Surface files in this folder.") return fileName = unmodified[0] startTime = time.time() carvePreferences = CarvePreferences() preferences.readPreferences(carvePreferences) print("File " + gcodec.getSummarizedFilename(fileName) + " is being carved.") carveGcode = getCarveGcode(fileName, carvePreferences) if carveGcode == "": return suffixFilename = fileName[: fileName.rfind(".")] + "_carve.svg" suffixFilename = suffixFilename.replace(" ", "_") gcodec.writeFileText(suffixFilename, carveGcode) print("The carved file is saved as " + gcodec.getSummarizedFilename(suffixFilename)) # packageFilePath = os.path.abspath( __file__ ) # for level in xrange( numberOfLevelsDeepInPackageHierarchy + 1 ): # packageFilePath = os.path.dirname( packageFilePath ) # documentationPath = os.path.join( os.path.join( packageFilePath, 'documentation' ), self.displayPreferences.fileNameHelp ) # os.system( webbrowser.get().name + ' ' + documentationPath )#used this instead of webbrowser.open() to workaround webbrowser open() bug # analyze.writeOutput( suffixFilename, carveGcode ) os.system( webbrowser.get().name + " " + suffixFilename ) # used this instead of webbrowser.open() to workaround webbrowser open() bug print("It took " + str(int(round(time.time() - startTime))) + " seconds to carve the file.")
def writeOutput( fileName = '' ): "Export a gcode linear move file." fileName = interpret.getFirstTranslatorFileNameUnmodified( fileName ) if fileName == '': return exportRepository = ExportRepository() preferences.getReadRepository( exportRepository ) startTime = time.time() print( 'File ' + gcodec.getSummarizedFilename( fileName ) + ' is being chain exported.' ) suffixFilename = fileName[ : fileName.rfind( '.' ) ] + '_export.' + exportRepository.fileExtension.value gcodeText = gcodec.getGcodeFileText( fileName, '' ) procedures = consecution.getProcedures( 'export', gcodeText ) gcodeText = consecution.getChainTextFromProcedures( fileName, procedures[ : - 1 ], gcodeText ) if gcodeText == '': return analyze.writeOutput( suffixFilename, gcodeText ) exportChainGcode = getCraftedTextFromText( gcodeText, exportRepository ) replacableExportChainGcode = None selectedPluginModule = getSelectedPluginModule( exportRepository.exportPlugins ) if selectedPluginModule == None: replacableExportChainGcode = exportChainGcode else: if selectedPluginModule.isReplacable(): replacableExportChainGcode = selectedPluginModule.getOutput( exportChainGcode ) else: selectedPluginModule.writeOutput( suffixFilename, exportChainGcode ) if replacableExportChainGcode != None: replacableExportChainGcode = getReplaced( replacableExportChainGcode ) gcodec.writeFileText( suffixFilename, replacableExportChainGcode ) print( 'The exported file is saved as ' + gcodec.getSummarizedFilename( suffixFilename ) ) if exportRepository.alsoSendOutputTo.value != '': if replacableExportChainGcode == None: replacableExportChainGcode = selectedPluginModule.getOutput( exportChainGcode ) exec( 'print >> ' + exportRepository.alsoSendOutputTo.value + ', replacableExportChainGcode' ) print( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to export the file.' )
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 writeOutput(fileName=''): """Export a gcode linear move file. Chain export the gcode if it is not already exported. If no fileName is specified, export the first unmodified gcode file in this folder.""" if fileName == '': unmodified = interpret.getGNUTranslatorFilesUnmodified() if len(unmodified) == 0: print("There are no unmodified gcode files in this folder.") return fileName = unmodified[0] exportPreferences = ExportPreferences() preferences.readPreferences(exportPreferences) startTime = time.time() print('File ' + gcodec.getSummarizedFilename(fileName) + ' is being chain exported.') suffixFilename = fileName[:fileName.rfind( '.')] + '.' + exportPreferences.fileExtension.value gcodeText = gcodec.getGcodeFileText(fileName, '') # if not gcodec.isProcedureDone( gcodeText, 'unpause' ): # gcodeText = unpause.getUnpauseChainGcode( fileName, gcodeText ) if not gcodec.isProcedureDone(gcodeText, 'raftless'): gcodeText = raftless.getRaftlessChainGcode(fileName, gcodeText) if gcodeText == '': return # Now prepend the start file and append the end file gcodeText = getStartText() + gcodeText + getEndText() analyze.writeOutput(suffixFilename, gcodeText) exportChainGcode = getExportGcode(gcodeText, exportPreferences) replacableExportChainGcode = None selectedPluginModule = getSelectedPlugin(exportPreferences) if selectedPluginModule == None: replacableExportChainGcode = exportChainGcode else: if selectedPluginModule.isReplacable(): replacableExportChainGcode = selectedPluginModule.getOutput( exportChainGcode) else: selectedPluginModule.writeOutput(suffixFilename, exportChainGcode) if replacableExportChainGcode != None: replacableExportChainGcode = getReplaced(replacableExportChainGcode) gcodec.writeFileText(suffixFilename, replacableExportChainGcode) print('The exported file is saved as ' + gcodec.getSummarizedFilename(suffixFilename)) if exportPreferences.alsoSendOutputTo.value != '': if replacableExportChainGcode == None: replacableExportChainGcode = selectedPluginModule.getOutput( exportChainGcode) exec('print >> ' + exportPreferences.alsoSendOutputTo.value + ', replacableExportChainGcode') print('It took ' + str(int(round(time.time() - startTime))) + ' seconds to export the file.')
def getReplacedSVGTemplateLines(self, fileName, rotatedBoundaryLayers): "Get the lines of text from the svg_template.txt file." #( layers.length + 1 ) * (margin + sliceDimY * unitScale + txtHeight) + margin + txtHeight + margin + 110 svgTemplateText = gcodec.getFileTextInFileDirectory( __file__, 'svg_template.svg') originalTextLines = gcodec.getTextLines(svgTemplateText) self.margin = getParameterFromJavascript(originalTextLines, 'margin', self.margin) self.textHeight = getParameterFromJavascript(originalTextLines, 'textHeight', self.textHeight) javascriptControlsWidth = getParameterFromJavascript( originalTextLines, 'javascripControlBoxX', 510.0) noJavascriptControlsHeight = getParameterFromJavascript( originalTextLines, 'noJavascriptControlBoxY', 110.0) controlTop = len(rotatedBoundaryLayers) * ( self.margin + self.extent.y * self.unitScale + self.textHeight) + 2.0 * self.margin + self.textHeight # width = margin + (sliceDimX * unitScale) + margin; svgTemplateText = getReplacedInQuotes( 'height', self.getRounded(controlTop + noJavascriptControlsHeight + self.margin), svgTemplateText) width = 2.0 * self.margin + max(self.extent.y * self.unitScale, javascriptControlsWidth) svgTemplateText = getReplacedInQuotes('width', self.getRounded(width), svgTemplateText) svgTemplateText = getReplacedWordAndInQuotes( 'layerThickness', self.getRounded(self.layerThickness), svgTemplateText) svgTemplateText = getReplacedWordAndInQuotes( 'maxX', self.getRounded(self.cornerMaximum.x), svgTemplateText) svgTemplateText = getReplacedWordAndInQuotes( 'minX', self.getRounded(self.cornerMinimum.x), svgTemplateText) svgTemplateText = getReplacedWordAndInQuotes( 'dimX', self.getRounded(self.extent.x), svgTemplateText) svgTemplateText = getReplacedWordAndInQuotes( 'maxY', self.getRounded(self.cornerMaximum.y), svgTemplateText) svgTemplateText = getReplacedWordAndInQuotes( 'minY', self.getRounded(self.cornerMinimum.y), svgTemplateText) svgTemplateText = getReplacedWordAndInQuotes( 'dimY', self.getRounded(self.extent.y), svgTemplateText) svgTemplateText = getReplacedWordAndInQuotes( 'maxZ', self.getRounded(self.cornerMaximum.z), svgTemplateText) svgTemplateText = getReplacedWordAndInQuotes( 'minZ', self.getRounded(self.cornerMinimum.z), svgTemplateText) svgTemplateText = getReplacedWordAndInQuotes( 'dimZ', self.getRounded(self.extent.z), svgTemplateText) summarizedFilename = gcodec.getSummarizedFilename( fileName) + ' SVG Slice File' svgTemplateText = getReplacedWordAndInQuotes('Title', summarizedFilename, svgTemplateText) noJavascriptControlsTagString = '<g id="noJavascriptControls" fill="#000" transform="translate(%s, %s)">' % ( self.getRounded(self.margin), self.getRounded(controlTop)) svgTemplateText = getReplacedTagString(noJavascriptControlsTagString, 'noJavascriptControls', svgTemplateText) # <g id="noJavascriptControls" fill="#000" transform="translate(20, 1400)"> return gcodec.getTextLines(svgTemplateText)
def getReplacedSVGTemplateLines( self, fileName, rotatedBoundaryLayers ): "Get the lines of text from the svg_template.tmpl file." #( layers.length + 1 ) * (margin + sliceDimY * unitScale + txtHeight) + margin + txtHeight + margin + 110 svgTemplateText = gcodec.getFileTextInFileDirectory( __file__, 'svg_template.tmpl' ) originalTextLines = gcodec.getTextLines( svgTemplateText ) self.margin = getParameterFromJavascript( originalTextLines, 'margin', self.margin ) self.textHeight = getParameterFromJavascript( originalTextLines, 'textHeight', self.textHeight ) javascriptControlsWidth = getParameterFromJavascript( originalTextLines, 'javascripControlBoxX', 510.0 ) noJavascriptControlsHeight = getParameterFromJavascript( originalTextLines, 'noJavascriptControlBoxY', 110.0 ) controlTop = len( rotatedBoundaryLayers ) * ( self.margin + self.extent.y * self.unitScale + self.textHeight ) + 2.0 * self.margin + self.textHeight # width = margin + (sliceDimX * unitScale) + margin; svgTemplateText = getReplacedInQuotes( 'height', self.getRounded( controlTop + noJavascriptControlsHeight + self.margin ), svgTemplateText ) width = 2.0 * self.margin + max( self.extent.y * self.unitScale, javascriptControlsWidth ) svgTemplateText = getReplacedInQuotes( 'width', self.getRounded( width ), svgTemplateText ) svgTemplateText = getReplacedWordAndInQuotes( 'layerThickness', self.getRounded( self.layerThickness ), svgTemplateText ) svgTemplateText = getReplacedWordAndInQuotes( 'maxX', self.getRounded( self.cornerMaximum.x ), svgTemplateText ) svgTemplateText = getReplacedWordAndInQuotes( 'minX', self.getRounded( self.cornerMinimum.x ), svgTemplateText ) svgTemplateText = getReplacedWordAndInQuotes( 'dimX', self.getRounded( self.extent.x ), svgTemplateText ) svgTemplateText = getReplacedWordAndInQuotes( 'maxY', self.getRounded( self.cornerMaximum.y ), svgTemplateText ) svgTemplateText = getReplacedWordAndInQuotes( 'minY', self.getRounded( self.cornerMinimum.y ), svgTemplateText ) svgTemplateText = getReplacedWordAndInQuotes( 'dimY', self.getRounded( self.extent.y ), svgTemplateText ) svgTemplateText = getReplacedWordAndInQuotes( 'maxZ', self.getRounded( self.cornerMaximum.z ), svgTemplateText ) svgTemplateText = getReplacedWordAndInQuotes( 'minZ', self.getRounded( self.cornerMinimum.z ), svgTemplateText ) svgTemplateText = getReplacedWordAndInQuotes( 'dimZ', self.getRounded( self.extent.z ), svgTemplateText ) summarizedFilename = gcodec.getSummarizedFilename( fileName ) + ' SVG Slice File' svgTemplateText = getReplacedWordAndInQuotes( 'Title', summarizedFilename, svgTemplateText ) noJavascriptControlsTagString = '<g id="noJavascriptControls" fill="#000" transform="translate(%s, %s)">' % ( self.getRounded( self.margin ), self.getRounded( controlTop ) ) svgTemplateText = getReplacedTagString( noJavascriptControlsTagString, 'noJavascriptControls', svgTemplateText ) # <g id="noJavascriptControls" fill="#000" transform="translate(20, 1400)"> return gcodec.getTextLines( svgTemplateText )
def writeStatisticFileGivenText( fileName, gcodeText, statisticPreferences ): "Write statistics for a gcode file." print( 'Statistics are being generated for the file ' + gcodec.getSummarizedFilename( fileName ) ) statisticGcode = getStatisticGcode( gcodeText ) if statisticPreferences.printStatistics.value: print( statisticGcode ) if statisticPreferences.saveStatistics.value: gcodec.writeFileMessageEnd( '.txt', fileName, statisticGcode, 'The statistics file is saved as ' )
def writeOutput( fileName = '' ): """Export a gcode linear move file. Chain export the gcode if it is not already exported. If no fileName is specified, export the first unmodified gcode file in this folder.""" if fileName == '': unmodified = interpret.getGNUTranslatorFilesUnmodified() if len( unmodified ) == 0: print( "There are no unmodified gcode files in this folder." ) return fileName = unmodified[ 0 ] exportPreferences = ExportPreferences() preferences.readPreferences( exportPreferences ) startTime = time.time() print( 'File ' + gcodec.getSummarizedFilename( fileName ) + ' is being chain exported.' ) suffixFilename = fileName[ : fileName.rfind( '.' ) ] + '.' + exportPreferences.fileExtension.value gcodeText = gcodec.getGcodeFileText( fileName, '' ) # if not gcodec.isProcedureDone( gcodeText, 'unpause' ): # gcodeText = unpause.getUnpauseChainGcode( fileName, gcodeText ) if not gcodec.isProcedureDone( gcodeText, 'raftless' ): gcodeText = raftless.getRaftlessChainGcode( fileName, gcodeText ) if gcodeText == '': return # Now prepend the start file and append the end file gcodeText = getStartText() + gcodeText + getEndText() analyze.writeOutput( suffixFilename, gcodeText ) exportChainGcode = getExportGcode( gcodeText, exportPreferences ) replacableExportChainGcode = None selectedPluginModule = getSelectedPlugin( exportPreferences ) if selectedPluginModule == None: replacableExportChainGcode = exportChainGcode else: if selectedPluginModule.isReplacable(): replacableExportChainGcode = selectedPluginModule.getOutput( exportChainGcode ) else: selectedPluginModule.writeOutput( suffixFilename, exportChainGcode ) if replacableExportChainGcode != None: replacableExportChainGcode = getReplaced( replacableExportChainGcode ) gcodec.writeFileText( suffixFilename, replacableExportChainGcode ) print( 'The exported file is saved as ' + gcodec.getSummarizedFilename( suffixFilename ) ) if exportPreferences.alsoSendOutputTo.value != '': if replacableExportChainGcode == None: replacableExportChainGcode = selectedPluginModule.getOutput( exportChainGcode ) exec( 'print >> ' + exportPreferences.alsoSendOutputTo.value + ', replacableExportChainGcode' ) print( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to export the file.' )
def writeOutput( fileName = '' ): "Clip a gcode linear move file. Chain clip the gcode if it is not already clipped. If no fileName is specified, clip the first unmodified gcode file in this folder." if fileName == '': unmodified = interpret.getGNUTranslatorFilesUnmodified() if len( unmodified ) == 0: print( "There are no unmodified gcode files in this folder." ) return fileName = unmodified[ 0 ] loopTailorPreferences = ClipPreferences() preferences.readPreferences( loopTailorPreferences ) startTime = time.time() print( 'File ' + gcodec.getSummarizedFilename( fileName ) + ' is being chain clipped.' ) suffixFilename = fileName[ : fileName.rfind( '.' ) ] + '_clip.gcode' loopTailorGcode = getClipChainGcode( fileName, '', loopTailorPreferences ) if loopTailorGcode == '': return gcodec.writeFileText( suffixFilename, loopTailorGcode ) print( 'The clipped file is saved as ' + gcodec.getSummarizedFilename( suffixFilename ) ) analyze.writeOutput( suffixFilename, loopTailorGcode ) print( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to clip the file.' )
def writeOutput( fileName = '' ): "Oozebane a gcode linear move file. Chain oozebane the gcode if it is not already oozebaned. If no fileName is specified, oozebane the first unmodified gcode file in this folder." if fileName == '': unmodified = interpret.getGNUTranslatorFilesUnmodified() if len( unmodified ) == 0: print( "There are no unmodified gcode files in this folder." ) return fileName = unmodified[ 0 ] oozebanePreferences = OozebanePreferences() preferences.readPreferences( oozebanePreferences ) startTime = time.time() print( 'File ' + gcodec.getSummarizedFilename( fileName ) + ' is being chain oozebaned.' ) suffixFilename = fileName[ : fileName.rfind( '.' ) ] + '_oozebane.gcode' oozebaneGcode = getOozebaneChainGcode( fileName, '', oozebanePreferences ) if oozebaneGcode == '': return gcodec.writeFileText( suffixFilename, oozebaneGcode ) print( 'The oozebaned file is saved as ' + gcodec.getSummarizedFilename( suffixFilename ) ) analyze.writeOutput( suffixFilename, oozebaneGcode ) print( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to oozebane the file.' )
def writeOutput( fileName = '' ): "Twitterbot a gcode file. Chain twitterbot the gcode if it is not already twitterbotted. If no fileName is specified, twitterbot the first unmodified gcode file in this folder." if fileName == '': unmodified = interpret.getGNUTranslatorFilesUnmodified() if len( unmodified ) == 0: print( "There are no unmodified gcode files in this folder." ) return fileName = unmodified[ 0 ] twitterbotPreferences = TwitterbotPreferences() preferences.readPreferences( twitterbotPreferences ) startTime = time.time() print( 'File ' + gcodec.getSummarizedFilename( fileName ) + ' is being chain twitterbotted.' ) suffixFilename = fileName[ : fileName.rfind( '.' ) ] + '_twitterbot.gcode' twitterbotGcode = getTwitterbotChainGcode( fileName, '', twitterbotPreferences ) if twitterbotGcode == '': return gcodec.writeFileText( suffixFilename, twitterbotGcode ) print( 'The twitterbotted file is saved as ' + gcodec.getSummarizedFilename( suffixFilename ) ) analyze.writeOutput( suffixFilename, twitterbotGcode ) print( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to add Twitterbot codes to the file.' )
def getFilenameWriteFiles( self, fileName ): "Write one or multiple files for the fileName." directoryName = os.path.dirname( fileName ) baseUnderscoredName = os.path.basename( fileName ).replace( ' ', '_' ) baseUnderscoredPrefix = baseUnderscoredName[ : baseUnderscoredName.rfind( '.' ) ] if not self.isMultiple: suffixFilename = os.path.join( directoryName, baseUnderscoredPrefix + '.svg' ) gcodec.writeFileText( suffixFilename, self.vectorWindow.getVectorFormattedText() ) return gcodec.getSummarizedFilename( suffixFilename ) multipleDirectoryName = os.path.join( directoryName, baseUnderscoredPrefix ) try: os.mkdir( multipleDirectoryName ) except OSError: pass suffixFilenames = [] indexFilename = os.path.join( multipleDirectoryName, 'index.html' ) for vectorWindowIndex in xrange( len( self.vectorWindows ) ): self.writeVectorWindowText( baseUnderscoredPrefix, multipleDirectoryName, suffixFilenames, vectorWindowIndex ) self.writeIndexText( baseUnderscoredPrefix, indexFilename, baseUnderscoredPrefix + ' Index', multipleDirectoryName, suffixFilenames ) return gcodec.getSummarizedFilename( indexFilename )
def writeOutput( fileName = '' ): "Unpause a gcode linear move file. Chain unpause the gcode if it is not already unpaused. If no fileName is specified, unpause the first unmodified gcode file in this folder." if fileName == '': unmodified = interpret.getGNUTranslatorFilesUnmodified() if len( unmodified ) == 0: print( "There are no unmodified gcode files in this folder." ) return fileName = unmodified[ 0 ] unpausePreferences = UnpausePreferences() preferences.readPreferences( unpausePreferences ) startTime = time.time() print( 'File ' + gcodec.getSummarizedFilename( fileName ) + ' is being chain unpaused.' ) suffixFilename = fileName[ : fileName.rfind( '.' ) ] + '_unpause.gcode' unpauseGcode = getUnpauseChainGcode( fileName, '', unpausePreferences ) if unpauseGcode == '': return gcodec.writeFileText( suffixFilename, unpauseGcode ) print( 'The unpaused file is saved as ' + gcodec.getSummarizedFilename( suffixFilename ) ) analyze.writeOutput( suffixFilename, unpauseGcode ) print( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to unpause the file.' )
def writeOutput( fileName = '' ): """Multiply a gcode linear move file. Chain multiply the gcode if it is not already multiplied. If no fileName is specified, multiply the first unmodified gcode file in this folder.""" if fileName == '': unmodified = interpret.getGNUTranslatorFilesUnmodified() if len( unmodified ) == 0: print( "There are no unmodified gcode files in this folder." ) return fileName = unmodified[ 0 ] multiplyPreferences = MultiplyPreferences() preferences.readPreferences( multiplyPreferences ) startTime = time.time() print( 'File ' + gcodec.getSummarizedFilename( fileName ) + ' is being chain multiplied.' ) suffixFilename = fileName[ : fileName.rfind( '.' ) ] + '_multiply.gcode' multiplyGcode = getMultiplyChainGcode( fileName, '', multiplyPreferences ) if multiplyGcode == '': return gcodec.writeFileText( suffixFilename, multiplyGcode ) print( 'The multiplied file is saved as ' + gcodec.getSummarizedFilename( suffixFilename ) ) analyze.writeOutput( suffixFilename, multiplyGcode ) print( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to multiply the file.' )
def writeOutput(fileName=""): """Speed a gcode linear move file. Chain speed the gcode if it is not already speeded. If no fileName is specified, speed the first unmodified gcode file in this folder.""" if fileName == "": unmodified = interpret.getGNUTranslatorFilesUnmodified() if len(unmodified) == 0: print("There are no unmodified gcode files in this folder.") return fileName = unmodified[0] speedPreferences = SpeedPreferences() preferences.readPreferences(speedPreferences) startTime = time.time() print("File " + gcodec.getSummarizedFilename(fileName) + " is being chain speeded.") suffixFilename = fileName[: fileName.rfind(".")] + "_speed.gcode" speedGcode = getSpeedChainGcode(fileName, "", speedPreferences) if speedGcode == "": return gcodec.writeFileText(suffixFilename, speedGcode) print("The speeded file is saved as " + gcodec.getSummarizedFilename(suffixFilename)) analyze.writeOutput(suffixFilename, speedGcode) print("It took " + str(int(round(time.time() - startTime))) + " seconds to speed the file.")
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 )
def writeOutput( fileName = '' ): print( "raftless - writeOutput" ) "Raftless a gcode linear move file. Chain raftless the gcode if it is not already raftless'd. If no fileName is specified, raftless the first unmodified gcode file in this folder." if fileName == '': unmodified = interpret.getGNUTranslatorFilesUnmodified() if len( unmodified ) == 0: print( "There are no unmodified gcode files in this folder." ) return fileName = unmodified[ 0 ] raftlessPreferences = RaftlessPreferences() preferences.readPreferences( raftlessPreferences ) print( ) startTime = time.time() print( "File " + gcodec.getSummarizedFilename( fileName ) + " is being chain raftless'd." ) suffixFilename = fileName[ : fileName.rfind( '.' ) ] + '_raftless.gcode' raftlessGcode = getRaftlessChainGcode( fileName, '', raftlessPreferences ) if raftlessGcode == '': return gcodec.writeFileText( suffixFilename, raftlessGcode ) print( 'The raftless file is saved as ' + gcodec.getSummarizedFilename( suffixFilename ) ) analyze.writeOutput( suffixFilename, raftlessGcode ) print( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to raftless the file.' )
def writeOutput( fileName = '' ): """Fillet a gcode linear move file. Chain fill the gcode if it is not already filled. Depending on the preferences, either arcPoint, arcRadius, arcSegment, bevel or do nothing. If no fileName is specified, fillet the first unmodified gcode file in this folder.""" if fileName == '': unmodified = interpret.getGNUTranslatorFilesUnmodified() if len( unmodified ) == 0: print( "There are no unmodified gcode files in this folder." ) return fileName = unmodified[ 0 ] filletPreferences = FilletPreferences() preferences.readPreferences( filletPreferences ) startTime = time.time() print( 'File ' + gcodec.getSummarizedFilename( fileName ) + ' is being chain filleted.' ) suffixFilename = fileName[ : fileName.rfind( '.' ) ] + '_fillet.gcode' filletGcode = getFilletChainGcode( fileName, '', filletPreferences ) if filletGcode == '': return gcodec.writeFileText( suffixFilename, filletGcode ) print( 'The filleted file is saved as ' + gcodec.getSummarizedFilename( suffixFilename ) ) analyze.writeOutput( suffixFilename, filletGcode ) print( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to fillet the file.' )
def writeOutput(fileName=''): """Multiply a gcode linear move file. Chain multiply the gcode if it is not already multiplied. If no fileName is specified, multiply the first unmodified gcode file in this folder.""" if fileName == '': unmodified = interpret.getGNUTranslatorFilesUnmodified() if len(unmodified) == 0: print("There are no unmodified gcode files in this folder.") return fileName = unmodified[0] multiplyPreferences = MultiplyPreferences() preferences.readPreferences(multiplyPreferences) startTime = time.time() print('File ' + gcodec.getSummarizedFilename(fileName) + ' is being chain multiplied.') suffixFilename = fileName[:fileName.rfind('.')] + '_multiply.gcode' multiplyGcode = getMultiplyChainGcode(fileName, '', multiplyPreferences) if multiplyGcode == '': return gcodec.writeFileText(suffixFilename, multiplyGcode) print('The multiplied file is saved as ' + gcodec.getSummarizedFilename(suffixFilename)) analyze.writeOutput(suffixFilename, multiplyGcode) print('It took ' + str(int(round(time.time() - startTime))) + ' seconds to multiply the file.')
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( "There are no unmodified gcode files in this folder." ) return fileName = unmodified[ 0 ] filletPreferences = FilletPreferences() preferences.readPreferences( filletPreferences ) print( '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' )
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( "There are no unmodified gcode files in this folder." ) return fileName = unmodified[ 0 ] filletPreferences = FilletPreferences() preferences.readPreferences( filletPreferences ) print( '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' )
def execute( self ): try: import tkFileDialog summarized = gcodec.getSummarizedFilename( self.value ) initialDirectory = os.path.dirname( summarized ) if len( initialDirectory ) > 0: initialDirectory += os.sep else: initialDirectory = "." fileName = tkFileDialog.askopenfilename( filetypes = self.getFilenameFirstTypes(), initialdir = initialDirectory, initialfile = os.path.basename( summarized ), title = self.name ) if ( str( fileName ) == '()' or str( fileName ) == '' ): self.wasCancelled = True else: self.value = fileName except: print( 'Oops, ' + self.name + ' could not get fileName.' )
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 execute(self): try: import tkFileDialog summarized = gcodec.getSummarizedFilename(self.value) initialDirectory = os.path.dirname(summarized) if len(initialDirectory) > 0: initialDirectory += os.sep else: initialDirectory = "." fileName = tkFileDialog.askopenfilename( filetypes=self.getFilenameFirstTypes(), initialdir=initialDirectory, initialfile=os.path.basename(summarized), title=self.name) if (str(fileName) == '()' or str(fileName) == ''): self.wasCancelled = True else: self.value = fileName except: print('Oops, ' + self.name + ' could not get fileName.')
def writeOutput( fileName = '' ): "Inset the carves of a gcode file. Chain carve the file if it is a GNU TriangulatedSurface file. If no fileName is specified, inset the first unmodified gcode file in this folder." if fileName == '': unmodified = interpret.getGNUTranslatorFilesUnmodified() if len( unmodified ) == 0: print( "There are no unmodified gcode files in this folder." ) return fileName = unmodified[ 0 ] startTime = time.time() insetPreferences = InsetPreferences() preferences.readPreferences( insetPreferences ) print( 'File ' + gcodec.getSummarizedFilename( fileName ) + ' is being chain insetted.' ) suffixFilename = fileName[ : fileName.rfind( '.' ) ] + '_inset.gcode' insetGcode = getInsetChainGcode( fileName, '', insetPreferences ) if insetGcode == '': return gcodec.writeFileText( suffixFilename, insetGcode ) print( 'The insetted file is saved as ' + suffixFilename ) analyze.writeOutput( suffixFilename, insetGcode ) print( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to inset the file.' )
def writeOutput(fileName=''): "Inset the carves of a gcode file. Chain carve the file if it is a GNU TriangulatedSurface file. If no fileName is specified, inset the first unmodified gcode file in this folder." if fileName == '': unmodified = interpret.getGNUTranslatorFilesUnmodified() if len(unmodified) == 0: print("There are no unmodified gcode files in this folder.") return fileName = unmodified[0] startTime = time.time() insetPreferences = InsetPreferences() preferences.readPreferences(insetPreferences) print('File ' + gcodec.getSummarizedFilename(fileName) + ' is being chain insetted.') suffixFilename = fileName[:fileName.rfind('.')] + '_inset.gcode' insetGcode = getInsetChainGcode(fileName, '', insetPreferences) if insetGcode == '': return gcodec.writeFileText(suffixFilename, insetGcode) print('The insetted file is saved as ' + suffixFilename) analyze.writeOutput(suffixFilename, insetGcode) print('It took ' + str(int(round(time.time() - startTime))) + ' seconds to inset the file.')