def execute(self): "Unpause button has been clicked." fileNames = polyfile.getFileOrDirectoryTypesUnmodifiedGcode( self.fileNameInput.value, interpret.getImportPluginFilenames(), self.fileNameInput.wasCancelled) for fileName in fileNames: writeOutput(fileName)
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 execute(self): "Comb button has been clicked." fileNames = polyfile.getFileOrDirectoryTypesUnmodifiedGcode( self.fileNameInput.value, interpret.getImportPluginFilenames(), self.fileNameInput.wasCancelled ) for fileName in fileNames: writeOutput(fileName)
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 getCarving(fileName): "Get a carving for the file using an import plugin." importPluginFilenames = interpret.getImportPluginFilenames() for importPluginFilename in importPluginFilenames: fileTypeDot = "." + importPluginFilename if fileName[-len(fileTypeDot) :].lower() == fileTypeDot: pluginModule = gcodec.getModule(importPluginFilename, "import_plugins", __file__) if pluginModule != None: return pluginModule.getCarving(fileName) print("Could not find plugin to handle " + fileName) return None
def getCarving(fileName): "Get a carving for the file using an import plugin." importPluginFilenames = interpret.getImportPluginFilenames() for importPluginFilename in importPluginFilenames: fileTypeDot = '.' + importPluginFilename if fileName[-len(fileTypeDot):].lower() == fileTypeDot: pluginModule = gcodec.getModule(importPluginFilename, 'import_plugins', __file__) if pluginModule != None: return pluginModule.getCarving(fileName) print('Could not find plugin to handle ' + fileName) return None
def getCarving( fileName ): "Get a carving for the file using an import plugin." importPluginFilenames = interpret.getImportPluginFilenames() for importPluginFilename in importPluginFilenames: fileTypeDot = '.' + importPluginFilename if fileName[ - len( fileTypeDot ) : ].lower() == fileTypeDot: importPluginsDirectoryPath = gcodec.getAbsoluteFolderPath( os.path.dirname( __file__ ), 'import_plugins' ) pluginModule = gcodec.getModuleWithDirectoryPath( importPluginsDirectoryPath, importPluginFilename ) if pluginModule != None: return pluginModule.getCarving( fileName ) print( 'Could not find plugin to handle ' + fileName ) return None
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 )