Exemple #1
0
 def execute(self):
     "Feed button has been clicked."
     fileNames = polyfile.getFileOrDirectoryTypesUnmodifiedGcode(
         self.fileNameInput.value, interpret.getImportPluginFileNames(),
         self.fileNameInput.wasCancelled)
     for fileName in fileNames:
         writeOutput(fileName)
Exemple #2
0
 def execute(self):
     "Chop button has been clicked."
     fileNames = polyfile.getFileOrDirectoryTypes(
         self.fileNameInput.value, interpret.getImportPluginFileNames(), self.fileNameInput.wasCancelled
     )
     for fileName in fileNames:
         writeOutput(fileName)
Exemple #3
0
def writeOutput(fileName=''):
    "Cleave a GNU Triangulated Surface file.  If no fileName is specified, cleave 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 cleaved.')
    cleaveGcode = getCraftedText(fileName)
    if cleaveGcode == '':
        return
    suffixFileName = fileName[:fileName.rfind('.')] + '_cleave.svg'
    suffixDirectoryName = os.path.dirname(suffixFileName)
    suffixReplacedBaseName = os.path.basename(suffixFileName).replace(' ', '_')
    suffixFileName = os.path.join(suffixDirectoryName, suffixReplacedBaseName)
    gcodec.writeFileText(suffixFileName, cleaveGcode)
    print('The cleaved file is saved as ' +
          gcodec.getSummarizedFileName(suffixFileName))
    print('It took ' + str(int(round(time.time() - startTime))) +
          ' seconds to cleave the file.')
    settings.openWebPage(suffixFileName)
Exemple #4
0
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
Exemple #5
0
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
Exemple #6
0
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.")
    settings.openWebPage(suffixFileName)
Exemple #7
0
def writeOutput( fileName = '' ):
	"Cleave a GNU Triangulated Surface file.  If no fileName is specified, cleave 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 cleaved.' )
	cleaveGcode = getCraftedText( fileName )
	if cleaveGcode == '':
		return
	suffixFileName = fileName[ : fileName.rfind( '.' ) ] + '_cleave.svg'
	suffixDirectoryName = os.path.dirname( suffixFileName )
	suffixReplacedBaseName = os.path.basename( suffixFileName ).replace( ' ', '_' )
	suffixFileName = os.path.join( suffixDirectoryName, suffixReplacedBaseName )
	gcodec.writeFileText( suffixFileName, cleaveGcode )
	print( 'The cleaved file is saved as ' + gcodec.getSummarizedFileName( suffixFileName ) )
	print( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to cleave the file.' )
	settings.openWebPage( suffixFileName )