def __init__(self): "Set the default preferences, execute title & preferences fileName." #Set the default preferences. self.archive = [] self.activateExport = preferences.BooleanPreference().getFromValue( 'Activate Export', True) self.archive.append(self.activateExport) self.alsoSendOutputTo = preferences.StringPreference().getFromValue( 'Also Send Output To:', '') self.archive.append(self.alsoSendOutputTo) self.deleteComments = preferences.BooleanPreference().getFromValue( 'Delete Comments', True) self.archive.append(self.deleteComments) self.deleteM110GcodeLine = preferences.BooleanPreference( ).getFromValue('Delete M110 Gcode Line', True) self.archive.append(self.deleteM110GcodeLine) exportPluginFilenames = gcodec.getPluginFilenames( 'export_plugins', __file__) self.exportLabel = preferences.LabelDisplay().getFromName( 'Export Operations: ') self.archive.append(self.exportLabel) self.exportOperations = [] self.exportPlugins = [] exportRadio = [] self.doNotChangeOutput = preferences.RadioCapitalized().getFromRadio( 'Do Not Change Output', exportRadio, True) for exportPluginFilename in exportPluginFilenames: exportPlugin = preferences.RadioCapitalized().getFromRadio( exportPluginFilename, exportRadio, False) self.exportPlugins.append(exportPlugin) self.exportOperations = [self.doNotChangeOutput] self.exportOperations += self.exportPlugins self.exportOperations.sort( key=preferences.RadioCapitalized.getLowerName) self.exportOperationsButtons = [] for exportOperation in self.exportOperations: self.exportOperationsButtons.append(exportOperation) if exportOperation != self.doNotChangeOutput: pluginModule = gcodec.getModule(exportOperation.name, 'export_plugins', __file__) if pluginModule != None: if pluginModule.isArchivable(): displayToolButtonBesidePrevious = preferences.DisplayToolButtonBesidePrevious( ).getFromFolderName('export_plugins', __file__, exportOperation.name) self.exportOperationsButtons.append( displayToolButtonBesidePrevious) self.archive += self.exportOperationsButtons self.fileExtension = preferences.StringPreference().getFromValue( 'File Extension:', 'gcode') self.archive.append(self.fileExtension) self.fileNameInput = preferences.Filename().getFromFilename( interpret.getGNUTranslatorGcodeFileTypeTuples(), 'Open File to be Exported', '') self.archive.append(self.fileNameInput) #Create the archive, title of the execute button, title of the dialog & preferences fileName. self.executeTitle = 'Export' self.saveTitle = 'Save Preferences' preferences.setHelpPreferencesFileNameTitleWindowPosition( self, 'skeinforge_tools.export.html')
def writeOutput( fileName = '' ): "Skeinforge a gcode file. If no fileName is specified, skeinforge the first gcode file in this folder that is not modified." skeinforgePluginFilenames = getSkeinforgeToolFilenames() toolNames = 'export raftless unpause fillet oozebane wipe hop stretch clip comb tower raft speed multiply fill inset carve'.split() for toolName in toolNames: for skeinforgePluginFilename in skeinforgePluginFilenames: if skeinforgePluginFilename == toolName: pluginModule = gcodec.getModule( skeinforgePluginFilename, 'skeinforge_tools', __file__ ) if pluginModule != None: pluginModule.writeOutput( fileName ) return
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 writeOutput( fileName = '', gcodeText = '' ): "Analyze a gcode file. If no fileName is specified, comment the first gcode file in this folder that is not modified." if fileName == '': unmodified = gcodec.getUncommentedGcodeFiles() if len( unmodified ) == 0: print( "There is no gcode file in this folder that is not a comment file." ) return fileName = unmodified[ 0 ] if gcodeText == '': gcodeText = gcodec.getFileText( fileName ) analyzePluginFilenames = getAnalyzePluginFilenames() for analyzePluginFilename in analyzePluginFilenames: pluginModule = gcodec.getModule( analyzePluginFilename, 'analyze_plugins', __file__ ) if pluginModule != None: pluginModule.writeOutput( fileName, gcodeText )
def __init__( self ): "Set the default preferences, execute title & preferences fileName." #Set the default preferences. self.archive = [] self.activateExport = preferences.BooleanPreference().getFromValue( 'Activate Export', True ) self.archive.append( self.activateExport ) self.alsoSendOutputTo = preferences.StringPreference().getFromValue( 'Also Send Output To:', '' ) self.archive.append( self.alsoSendOutputTo ) self.deleteComments = preferences.BooleanPreference().getFromValue( 'Delete Comments', True ) self.archive.append( self.deleteComments ) self.deleteM110GcodeLine = preferences.BooleanPreference().getFromValue( 'Delete M110 Gcode Line', True ) self.archive.append( self.deleteM110GcodeLine ) exportPluginFilenames = gcodec.getPluginFilenames( 'export_plugins', __file__ ) self.exportLabel = preferences.LabelDisplay().getFromName( 'Export Operations: ' ) self.archive.append( self.exportLabel ) self.exportOperations = [] self.exportPlugins = [] exportRadio = [] self.doNotChangeOutput = preferences.RadioCapitalized().getFromRadio( 'Do Not Change Output', exportRadio, True ) for exportPluginFilename in exportPluginFilenames: exportPlugin = preferences.RadioCapitalized().getFromRadio( exportPluginFilename, exportRadio, False ) self.exportPlugins.append( exportPlugin ) self.exportOperations = [ self.doNotChangeOutput ] self.exportOperations += self.exportPlugins self.exportOperations.sort( key = preferences.RadioCapitalized.getLowerName ) self.exportOperationsButtons = [] for exportOperation in self.exportOperations: self.exportOperationsButtons.append( exportOperation ) if exportOperation != self.doNotChangeOutput: pluginModule = gcodec.getModule( exportOperation.name, 'export_plugins', __file__ ) if pluginModule != None: if pluginModule.isArchivable(): displayToolButtonBesidePrevious = preferences.DisplayToolButtonBesidePrevious().getFromFolderName( 'export_plugins', __file__, exportOperation.name ) self.exportOperationsButtons.append( displayToolButtonBesidePrevious ) self.archive += self.exportOperationsButtons self.fileExtension = preferences.StringPreference().getFromValue( 'File Extension:', 'gcode' ) self.archive.append( self.fileExtension ) self.fileNameInput = preferences.Filename().getFromFilename( interpret.getGNUTranslatorGcodeFileTypeTuples(), 'Open File to be Exported', '' ) self.archive.append( self.fileNameInput ) #Create the archive, title of the execute button, title of the dialog & preferences fileName. self.executeTitle = 'Export' self.saveTitle = 'Save Preferences' preferences.setHelpPreferencesFileNameTitleWindowPosition( self, 'skeinforge_tools.export.html' )
def displayTool(self): "Display the tool preferences dialog." pluginModule = gcodec.getModule(self.name, self.folderName, self.moduleFilename) if pluginModule != None: pluginModule.main()
def getSelectedPlugin( exportPreferences ): "Get the selected plugin module." for plugin in exportPreferences.exportPlugins: if plugin.value: return gcodec.getModule( plugin.name, 'export_plugins', __file__ ) return None
def displayTool( self ): "Display the tool preferences dialog." pluginModule = gcodec.getModule( self.name, self.folderName, self.moduleFilename ) if pluginModule != None: pluginModule.main()
def getSelectedPlugin(exportPreferences): "Get the selected plugin module." for plugin in exportPreferences.exportPlugins: if plugin.value: return gcodec.getModule(plugin.name, 'export_plugins', __file__) return None