Beispiel #1
0
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.')
Beispiel #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)
Beispiel #4
0
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.")
Beispiel #5
0
	def addInitializationToOutput( self ):
		"Add initialization gcode to the output."
		self.addFromUpperLowerFile( self.prefacePreferences.nameOfStartFile.value ) # Add a start file if it exists.
		self.distanceFeedRate.addTagBracketedLine( 'creator', 'skeinforge' ) # GCode formatted comment
		absoluteFilePathUntilDot = os.path.abspath( __file__ )[ : os.path.abspath( __file__ ).rfind( '.' ) ]
		if absoluteFilePathUntilDot == '/home/enrique/Desktop/backup/babbleold/script/reprap/pyRepRap/skeinforge_tools/craft_plugins/preface': #check to see if this script is on Enrique's computer
			gcodec.writeFileText( gcodec.getVersionFileName(), date.today().isoformat() )
		versionText = gcodec.getFileText( gcodec.getVersionFileName() )
		self.distanceFeedRate.addTagBracketedLine( 'version', versionText ) # GCode formatted comment
		self.distanceFeedRate.addLine( '(<extruderInitialization>)' ) # GCode formatted comment
		if self.prefacePreferences.setPositioningToAbsolute.value:
			self.distanceFeedRate.addLine( 'G90' ) # Set positioning to absolute.
		if self.prefacePreferences.setUnitsToMillimeters.value:
			self.distanceFeedRate.addLine( 'G21' ) # Set units to millimeters.
		if self.prefacePreferences.startAtHome.value:
			self.distanceFeedRate.addLine( 'G28' ) # Start at home.
		if self.prefacePreferences.turnExtruderOffAtStartUp.value:
			self.distanceFeedRate.addLine( 'M103' ) # Turn extruder off.
		self.distanceFeedRate.addTagBracketedLine( 'decimalPlacesCarried', self.distanceFeedRate.decimalPlacesCarried )
		if self.prefacePreferences.extrusionDistanceAbsolutePreference.value:
			self.distanceFeedRate.extrusionDistanceFormat = 'absolute'
		if self.prefacePreferences.extrusionDistanceRelativePreference.value:
			self.distanceFeedRate.extrusionDistanceFormat = 'relative'
		if self.distanceFeedRate.extrusionDistanceFormat != '':
			self.distanceFeedRate.addTagBracketedLine( 'extrusionDistanceFormat', self.distanceFeedRate.extrusionDistanceFormat )
		self.distanceFeedRate.addTagBracketedLine( 'layerThickness', self.distanceFeedRate.getRounded( self.layerThickness ) )
		self.distanceFeedRate.addTagBracketedLine( 'perimeterWidth', self.distanceFeedRate.getRounded( self.perimeterWidth ) )
		self.distanceFeedRate.addTagBracketedLine( 'procedureDone', 'carve' )
		self.distanceFeedRate.addTagBracketedLine( 'procedureDone', 'preface' )
		self.distanceFeedRate.addLine( '(</extruderInitialization>)' ) # Initialization is finished, extrusion is starting.
		self.distanceFeedRate.addLine( '(<extrusion>)' ) # Initialization is finished, extrusion is starting.
Beispiel #6
0
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.' )
Beispiel #7
0
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.')
Beispiel #8
0
def readWriteDeleteHypertextHelp( documentDirectoryPath, fileName ):
	"Read the pydoc hypertext help documents, write them in the documentation folder then delete the originals."
	print( fileName )
	filePath = os.path.join( documentDirectoryPath, fileName )
	fileText = gcodec.getFileText( fileName )
	fileText = getWrappedHypertext( fileText )
	gcodec.writeFileText( filePath, fileText )
	os.remove( fileName )
Beispiel #9
0
def readWriteNavigationHelp( documentDirectoryPath, transferredFileNameIndex, transferredFileNames ):
	"Read the hypertext help documents, and add the navigation lines to them."
	fileName = transferredFileNames[ transferredFileNameIndex ]
	print( fileName )
	filePath = os.path.join( documentDirectoryPath, fileName )
	fileText = gcodec.getFileText( filePath )
	fileText = getNavigationHypertext( fileText, transferredFileNameIndex, transferredFileNames )
	gcodec.writeFileText( filePath, fileText )
Beispiel #10
0
def writeOutput( fileName, gcodeText = '' ):
	"Write the exported version of a gcode file."
	gcodeText = gcodec.getGcodeFileText( fileName, gcodeText )
	repository = GcodeStepRepository()
	settings.getReadRepository( repository )
	output = getOutput( gcodeText, repository )
	suffixFileName = fileName[ : fileName.rfind( '.' ) ] + '_gcode_step.gcode'
	gcodec.writeFileText( suffixFileName, output )
	print( 'The converted file is saved as ' + gcodec.getSummarizedFileName( suffixFileName ) )
Beispiel #11
0
def writeOutput( fileName, gcodeText = '' ):
	"Write the exported version of a gcode file."
	binary16ByteRepository = Binary16ByteRepository()
	settings.getReadRepository( binary16ByteRepository )
	gcodeText = gcodec.getGcodeFileText( fileName, gcodeText )
	skeinOutput = getOutput( gcodeText, binary16ByteRepository )
	suffixFileName = fileName[ : fileName.rfind( '.' ) ] + '.' + binary16ByteRepository.fileExtension.value
	gcodec.writeFileText( suffixFileName, skeinOutput )
	print( 'The converted file is saved as ' + gcodec.getSummarizedFileName( suffixFileName ) )
	def writeIndexText( self, baseUnderscoredPrefix, indexFilename, indexName, multipleDirectoryName, suffixFilenames ):
		"Write the text for the index page."
		indexText = cStringIO.StringIO()
		indexText.write( '<html>\n<head>\n  <title>%s</title>\n</head>\n<body>\n' % indexName )
		for suffixFilename in suffixFilenames:
			indexText.write( '<a href="%s">%s</a><br />\n' % ( suffixFilename[ : - 3 ] + 'html', os.path.basename( suffixFilename )[ : - 4 ] ) )
		nextFilename = self.getHypertextLinkBasename( baseUnderscoredPrefix, 0 )
		previousFilename = self.getHypertextLinkBasename( baseUnderscoredPrefix, len( self.vectorWindows ) - 1 )
		indexText.write( '  <br />\n  <br />\n<a href="%s"><- Previous</a> Index <a href="%s">Next -></a>\n' % ( previousFilename, nextFilename ) )
		indexText.write( '</body>\n</html>' )
		gcodec.writeFileText( indexFilename, indexText.getvalue() )
Beispiel #13
0
def writeOutput(fileName, gcodeText=''):
    "Write the exported version of a gcode file."
    binary16ByteRepository = Binary16ByteRepository()
    settings.getReadRepository(binary16ByteRepository)
    gcodeText = gcodec.getGcodeFileText(fileName, gcodeText)
    skeinOutput = getOutput(gcodeText, binary16ByteRepository)
    suffixFileName = fileName[:fileName.rfind(
        '.')] + '.' + binary16ByteRepository.fileExtension.value
    gcodec.writeFileText(suffixFileName, skeinOutput)
    print('The converted file is saved as ' +
          gcodec.getSummarizedFileName(suffixFileName))
Beispiel #14
0
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)
Beispiel #15
0
def readWriteDeleteHypertextHelp( documentDirectoryPath, hypertextFileIndex, hypertextFiles, transferredFileNames ):
	"Read the pydoc hypertext help documents, write them in the documentation folder then delete the originals."
	fileName = hypertextFiles[ hypertextFileIndex ]
	print( fileName )
	filePath = os.path.join( documentDirectoryPath, fileName )
	fileText = gcodec.getFileText( fileName )
	fileText = getWrappedHypertext( fileText, hypertextFileIndex, hypertextFiles )
	if fileText.find( 'This page is in the table of contents.' ) > - 1:
		fileText = fileText.replace( 'This page is in the table of contents.', '' )
		transferredFileNames.append( fileName )
	gcodec.writeFileText( filePath, fileText )
	os.remove( fileName )
Beispiel #16
0
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.')
Beispiel #17
0
def writeContentsFile( documentDirectoryPath, hypertextFiles ):
	"Write the contents file."
	output = cStringIO.StringIO()
	output.write( '<html>\n  <head>\n    <title>Contents</title>\n  </head>\n  <body>\n' )
	navigationLine = getNavigationLine( 'Contents', 'Previous', getNextLinkText( hypertextFiles, 0 ) )
	output.write( navigationLine )
	for hypertextFile in hypertextFiles:
		writeContentsLine( hypertextFile, output )
	output.write( navigationLine )
	output.write( '  </body>\n</html>\n' )
	filePath = os.path.join( documentDirectoryPath, 'contents.html' )
	gcodec.writeFileText( filePath, output.getvalue() )
Beispiel #18
0
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.' )
	settings.openWebPage( suffixFileName )
Beispiel #19
0
def writeOutput(fileName=''):
    "Export a gcode linear move file."
    fileName = interpret.getFirstTranslatorFileNameUnmodified(fileName)
    if fileName == '':
        return
    exportRepository = ExportRepository()
    settings.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)
    if exportRepository.savePenultimateGcode.value:
        penultimateFileName = fileName[:fileName.
                                       rfind('.')] + '_penultimate.gcode'
        gcodec.writeFileText(penultimateFileName, gcodeText)
        print('The penultimate file is saved as ' +
              gcodec.getSummarizedFileName(penultimateFileName))
    exportChainGcode = getCraftedTextFromText(gcodeText, exportRepository)
    replaceableExportChainGcode = None
    selectedPluginModule = getSelectedPluginModule(
        exportRepository.exportPlugins)
    if selectedPluginModule == None:
        replaceableExportChainGcode = exportChainGcode
    else:
        if selectedPluginModule.isReplaceable():
            replaceableExportChainGcode = selectedPluginModule.getOutput(
                exportChainGcode)
        else:
            selectedPluginModule.writeOutput(suffixFileName, exportChainGcode)
    if replaceableExportChainGcode != None:
        replaceableExportChainGcode = getReplaced(replaceableExportChainGcode)
        gcodec.writeFileText(suffixFileName, replaceableExportChainGcode)
        print('The exported file is saved as ' +
              gcodec.getSummarizedFileName(suffixFileName))
    if exportRepository.alsoSendOutputTo.value != '':
        if replaceableExportChainGcode == None:
            replaceableExportChainGcode = selectedPluginModule.getOutput(
                exportChainGcode)
        exec('print >> ' + exportRepository.alsoSendOutputTo.value +
             ', replaceableExportChainGcode')
    print('It took ' + str(int(round(time.time() - startTime))) +
          ' seconds to export the file.')
Beispiel #20
0
 def addInitializationToOutput(self):
     "Add initialization gcode to the output."
     self.addFromUpperLowerFile(self.prefaceRepository.nameOfStartFile.value
                                )  # Add a start file if it exists.
     self.distanceFeedRate.addTagBracketedLine(
         'creator', 'skeinforge')  # GCode formatted comment
     absoluteFilePathUntilDot = os.path.abspath(
         __file__)[:os.path.abspath(__file__).rfind('.')]
     if absoluteFilePathUntilDot == '/home/enrique/Desktop/backup/babbleold/script/reprap/pyRepRap/skeinforge_tools/craft_plugins/preface':  #check to see if this script is on Enrique's computer
         gcodec.writeFileText(gcodec.getVersionFileName(),
                              date.today().isoformat())
     versionText = gcodec.getFileText(gcodec.getVersionFileName())
     self.distanceFeedRate.addTagBracketedLine(
         'version', versionText)  # GCode formatted comment
     self.distanceFeedRate.addLine(
         '(<extruderInitialization>)')  # GCode formatted comment
     if self.prefaceRepository.setPositioningToAbsolute.value:
         self.distanceFeedRate.addLine(
             'G90')  # Set positioning to absolute.
     if self.prefaceRepository.setUnitsToMillimeters.value:
         self.distanceFeedRate.addLine('G21')  # Set units to millimeters.
     if self.prefaceRepository.startAtHome.value:
         self.distanceFeedRate.addLine('G28')  # Start at home.
     if self.prefaceRepository.turnExtruderOffAtStartUp.value:
         self.distanceFeedRate.addLine('M103')  # Turn extruder off.
     craftTypeName = profile.getCraftTypeName()
     self.distanceFeedRate.addTagBracketedLine('craftTypeName',
                                               craftTypeName)
     self.distanceFeedRate.addTagBracketedLine(
         'decimalPlacesCarried', self.distanceFeedRate.decimalPlacesCarried)
     self.distanceFeedRate.addTagBracketedLine(
         'layerThickness',
         self.distanceFeedRate.getRounded(self.layerThickness))
     if self.prefaceRepository.meta.value:
         self.distanceFeedRate.addTagBracketedLine(
             'meta', self.prefaceRepository.meta.value)
     self.distanceFeedRate.addTagBracketedLine(
         'perimeterWidth',
         self.distanceFeedRate.getRounded(self.perimeterWidth))
     self.distanceFeedRate.addTagBracketedLine(
         'profileName', profile.getProfileName(craftTypeName))
     self.distanceFeedRate.addTagBracketedLine('procedureDone', 'carve')
     self.distanceFeedRate.addTagBracketedLine('procedureDone', 'preface')
     self.distanceFeedRate.addLine(
         '(</extruderInitialization>)'
     )  # Initialization is finished, extrusion is starting.
     self.distanceFeedRate.addLine(
         '(<extrusion>)'
     )  # Initialization is finished, extrusion is starting.
Beispiel #21
0
	def execute( self ):
		"Export the canvas as an svg file."
		svgFileName = gcodec.getFilePathWithUnderscoredBasename( self.fileName, self.suffix )
		boundingBox = self.canvas.bbox( settings.Tkinter.ALL ) # tuple (w, n, e, s)
		self.boxW = boundingBox[ 0 ]
		self.boxN = boundingBox[ 1 ]
		boxWidth = boundingBox[ 2 ] - self.boxW
		boxHeight = boundingBox[ 3 ] - self.boxN
		print( 'Exported svg file saved as ' + svgFileName )
		svgTemplateText = gcodec.getFileTextInFileDirectory( settings.__file__, 'svg_canvas.template' )
		output = cStringIO.StringIO()
		lines = gcodec.getTextLines( svgTemplateText )
		firstWordTable = {}
		firstWordTable[ 'height="999px"' ] = '		height="%spx"' % int( round( boxHeight ) )
		firstWordTable[ '<!--replaceLineWith_coloredLines-->' ] = self.getCanvasLinesOutput()
		firstWordTable[ 'replaceLineWithTitle' ] = gcodec.getSummarizedFileName( self.fileName )
		firstWordTable[ 'width="999px"' ] = '		width="%spx"' % int( round( boxWidth ) )
		for line in lines:
			parseLineReplace( firstWordTable, line, output )
		gcodec.writeFileText( svgFileName, output.getvalue() )
		fileExtension = self.fileExtension.value
		svgProgram = self.svgProgram.value
		if svgProgram == '':
			return
		if svgProgram == 'webbrowser':
			settings.openWebPage( svgFileName )
			return
		svgFilePath = '"' + os.path.normpath( svgFileName ) + '"' # " to send in file name with spaces
		shellCommand = svgProgram + ' ' + svgFilePath
		print( '' )
		if fileExtension == '':
			print( 'Sending the shell command:' )
			print( shellCommand )
			commandResult = os.system( shellCommand )
			if commandResult != 0:
				print( 'It may be that the system could not find the %s program.' % svgProgram )
				print( 'If so, try installing the %s program or look for another one, like the Gnu Image Manipulation Program (Gimp) which can be found at:' % svgProgram )
				print( 'http://www.gimp.org/' )
			return
		convertedFileName = gcodec.getFilePathWithUnderscoredBasename( svgFilePath, '.' + fileExtension + '"' )
		shellCommand += ' ' + convertedFileName
		print( 'Sending the shell command:' )
		print( shellCommand )
		commandResult = os.system( shellCommand )
		if commandResult != 0:
			print( 'The %s program could not convert the svg to the %s file format.' % ( svgProgram, fileExtension ) )
			print( 'Try installing the %s program or look for another one, like Image Magick which can be found at:' % svgProgram )
			print( 'http://www.imagemagick.org/script/index.php' )
Beispiel #22
0
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 )
Beispiel #23
0
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)
Beispiel #24
0
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.')
    settings.openWebPage(suffixFileName)
Beispiel #25
0
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.' )
Beispiel #26
0
def analyzeFileGivenText( fileName, gcodeText, repository = None ):
	"Write scalable vector graphics for a gcode file given the settings."
	if gcodeText == '':
		return ''
	if repository == None:
		repository = settings.getReadRepository( VectorwriteRepository() )
	startTime = time.time()
	vectorwriteGcode = VectorwriteSkein().getSVG( fileName, gcodeText, repository )
	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.' )
	settings.openWebPage( suffixFileName )
Beispiel #27
0
def writeChainTextWithNounMessage( fileName, procedure ):
	"Get and write a crafted shape file."
	print( '' )
	print( 'The %s tool is parsing the file:' % procedure )
	print( os.path.basename( fileName ) )
	print( '' )
	startTime = time.time()
	suffixFilename = fileName[ : fileName.rfind( '.' ) ] + '_' + procedure + '.gcode'
	craftText = getChainText( fileName, procedure )
	if craftText == '':
		return
	gcodec.writeFileText( suffixFilename, craftText )
	print( '' )
	print( 'The %s tool has created the file:' % procedure )
	print( suffixFilename )
	print( '' )
	print( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to craft the file.' )
	analyze.writeOutput( suffixFilename, craftText )
Beispiel #28
0
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.' )
Beispiel #29
0
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 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 )
Beispiel #31
0
def writeChainTextWithNounMessage(fileName, procedure):
    "Get and write a crafted shape file."
    print('')
    print('The %s tool is parsing the file:' % procedure)
    print(os.path.basename(fileName))
    print('')
    startTime = time.time()
    suffixFileName = fileName[:fileName.rfind('.'
                                              )] + '_' + procedure + '.gcode'
    craftText = getChainText(fileName, procedure)
    if craftText == '':
        return
    gcodec.writeFileText(suffixFileName, craftText)
    print('')
    print('The %s tool has created the file:' % procedure)
    print(suffixFileName)
    print('')
    print('It took ' + str(int(round(time.time() - startTime))) +
          ' seconds to craft the file.')
    analyze.writeOutput(suffixFileName, craftText)
Beispiel #32
0
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.' )
Beispiel #33
0
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.' )
Beispiel #34
0
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.' )
Beispiel #35
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)
Beispiel #36
0
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 writeVectorWindowText( self, baseUnderscoredPrefix, multipleDirectoryName, suffixFilenames, vectorWindowIndex ):
		"Write the text for a vector window page."
		suffixFilename = self.getSuffixFilename( baseUnderscoredPrefix, multipleDirectoryName, vectorWindowIndex )
		vectorWindow = self.vectorWindows[ vectorWindowIndex ]
		gcodec.writeFileText( suffixFilename, vectorWindow.getVectorFormattedText() )
		htmlPageFilename = suffixFilename[ : - 3 ] + 'html'
		hypertext = cStringIO.StringIO()
		suffixBasename = os.path.basename( suffixFilename )
		suffixFilenames.append( suffixBasename )
		hypertext.write( '<html>\n<head>\n  <title>%s</title>\n</head>\n<body>\n' % suffixBasename[ : - 4 ] )
		hypertext.write( '  <object type="image/svg+xml" data="%s" %s>  </object><br />\n  <br />\n' % ( suffixBasename, vectorWindow.getHeightWidthString() ) )
#		hypertext.write( '  <iframe src="%s" %s>  </iframe>\n' % ( suffixBasename, vectorWindow.getHeightWidthString() ) )
		nextFilename = 'index.html'
		if vectorWindowIndex < len( self.vectorWindows ) - 1:
			nextFilename = self.getHypertextLinkBasename( baseUnderscoredPrefix, vectorWindowIndex + 1 )
		previousFilename = 'index.html'
		if vectorWindowIndex > 0:
			previousFilename = self.getHypertextLinkBasename( baseUnderscoredPrefix, vectorWindowIndex - 1 )
		hypertext.write( '<a href="%s"><- Previous</a> <a href="%s">Index</a> <a href="%s">Next -></a>\n' % ( previousFilename, 'index.html', nextFilename ) )
		hypertext.write( '</body>\n</html>' )
		gcodec.writeFileText( htmlPageFilename, hypertext.getvalue() )
Beispiel #38
0
def analyzeFileGivenText(fileName, gcodeText, repository=None):
    "Write scalable vector graphics for a gcode file given the settings."
    if gcodeText == '':
        return ''
    if repository == None:
        repository = settings.getReadRepository(VectorwriteRepository())
    startTime = time.time()
    vectorwriteGcode = VectorwriteSkein().getSVG(fileName, gcodeText,
                                                 repository)
    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.')
    settings.openWebPage(suffixFileName)
Beispiel #39
0
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.' )
Beispiel #40
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.' )
	preferences.openWebPage( suffixFilename )
Beispiel #41
0
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.' )
Beispiel #42
0
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.')
Beispiel #43
0
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.' )
Beispiel #44
0
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 writePreferences(archivablePreferences):
    "Write the preferences to a file."
    gcodec.writeFileText(archivablePreferences.fileNamePreferences,
                         getArchiveText(archivablePreferences))