Beispiel #1
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( 'creation', 'skeinforge' ) # GCode formatted comment
		absoluteFilePathUntilDot = os.path.abspath( __file__ )[ : os.path.abspath( __file__ ).rfind( '.' ) ]
		if absoluteFilePathUntilDot == '/home/enrique/Desktop/backup/babbleold/script/reprap/fabmetheus/skeinforge_application/skeinforge_plugins/craft_plugins/preface': #is this script 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 = skeinforge_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', skeinforge_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.
def getWindowAnalyzeFile(fileName):
	"Get file interpretion."
	startTime = time.time()
	carving = getCarving(fileName)
	if carving == None:
		return None
	interpretGcode = str( carving )
	if interpretGcode == '':
		return None
	repository = settings.getReadRepository( InterpretRepository() )
	if repository.printInterpretion.value:
		print( interpretGcode )
	suffixFileName = fileName[ : fileName.rfind('.') ] + '_interpret.' + carving.getInterpretationSuffix()
	suffixDirectoryName = os.path.dirname(suffixFileName)
	suffixReplacedBaseName = os.path.basename(suffixFileName).replace(' ', '_')
	suffixFileName = os.path.join( suffixDirectoryName, suffixReplacedBaseName )
	gcodec.writeFileText( suffixFileName, interpretGcode )
	print('The interpret file is saved as ' + gcodec.getSummarizedFileName(suffixFileName) )
	print('It took %s to interpret the file.' % euclidean.getDurationString( time.time() - startTime ) )
	textProgram = repository.textProgram.value
	if textProgram == '':
		return None
	if textProgram == 'webbrowser':
		settings.openWebPage(suffixFileName)
		return None
	textFilePath = '"' + os.path.normpath(suffixFileName) + '"' # " to send in file name with spaces
	shellCommand = textProgram + ' ' + textFilePath
	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.' % textProgram )
		print('If so, try installing the %s program or look for another one, like Open Office which can be found at:' % textProgram )
		print('http://www.openoffice.org/')
		print('Open office writer can then be started from the command line with the command "soffice -writer".')
def analyzeFile( fileName ):
	"Get file interpretion."
	startTime = time.time()
	carving = getCarving( fileName )
	if carving == None:
		return ''
	interpretGcode = str( carving )
	if interpretGcode == '':
		return
	repository = settings.getReadRepository( InterpretRepository() )
	if repository.printInterpretion.value:
		print( interpretGcode )
	suffixFileName = fileName[ : fileName.rfind( '.' ) ] + '_interpret.' + carving.getInterpretationSuffix()
	suffixDirectoryName = os.path.dirname( suffixFileName )
	suffixReplacedBaseName = os.path.basename( suffixFileName ).replace( ' ', '_' )
	suffixFileName = os.path.join( suffixDirectoryName, suffixReplacedBaseName )
	gcodec.writeFileText( suffixFileName, interpretGcode )
	print( 'The interpret file is saved as ' + gcodec.getSummarizedFileName( suffixFileName ) )
	print( 'It took %s to interpret the file.' % euclidean.getDurationString( time.time() - startTime ) )
	textProgram = repository.textProgram.value
	if textProgram == '':
		return
	if textProgram == 'webbrowser':
		settings.openWebPage( suffixFileName )
		return
	textFilePath = '"' + os.path.normpath( suffixFileName ) + '"' # " to send in file name with spaces
	shellCommand = textProgram + ' ' + textFilePath
	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.' % textProgram )
		print( 'If so, try installing the %s program or look for another one, like Open Office which can be found at:' % textProgram )
		print( 'http://www.openoffice.org/' )
		print( 'Open office writer can then be started from the command line with the command "soffice -writer".' )
Beispiel #4
0
def writeXMLElement(fileNames, target, xmlElement):
    "Write target."
    object = target.object
    if object == None:
        print('Warning, writeTarget in write could not get object for:')
        print(xmlElement)
        return
    fileNameRoot = evaluate.getEvaluatedStringDefault('', 'name', target)
    fileNameRoot = evaluate.getEvaluatedStringDefault(fileNameRoot, 'id',
                                                      target)
    fileNameRoot = evaluate.getEvaluatedStringDefault(fileNameRoot, 'file',
                                                      xmlElement)
    fileNameRoot += evaluate.getEvaluatedStringDefault('', 'suffix',
                                                       xmlElement)
    extension = evaluate.getEvaluatedStringDefault(
        object.getFabricationExtension(), 'extension', xmlElement)
    fileName = '%s.%s' % (fileNameRoot, extension)
    suffixIndex = 1
    while fileName in fileNames:
        fileName = '%s_%s.%s' % (fileNameRoot, suffixIndex, extension)
        suffixIndex += 1
    fileNames.append(fileName)
    folderName = evaluate.getEvaluatedStringDefault('', 'folder', xmlElement)
    absoluteFolderDirectory = os.path.join(
        os.path.dirname(xmlElement.getRoot().parser.fileName), folderName)
    gcodec.makeDirectory(absoluteFolderDirectory)
    gcodec.writeFileText(os.path.join(absoluteFolderDirectory, fileName),
                         object.getFabricationText())
Beispiel #5
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(
            fabmetheus_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 #6
0
def writeOutput(fileName=''):
    "Export a gcode linear move file."
    fileName = fabmetheus_interpret.getFirstTranslatorFileNameUnmodified(
        fileName)
    if fileName == '':
        return
    exportRepository = ExportRepository()
    settings.getReadRepository(exportRepository)
    startTime = time.time()
    print('File ' + gcodec.getSummarizedFileName(fileName) +
          ' is being chain exported.')
    Filehandle = open('report.txt', 'w')
    Filehandle.write('File ' + gcodec.getSummarizedFileName(fileName) +
                     ' is being chain exported.\n')
    Filehandle.close()
    suffixFileName = fileName[:fileName.rfind(
        '.')] + '_export.' + exportRepository.fileExtension.value
    gcodeText = gcodec.getGcodeFileText(fileName, '')
    procedures = skeinforge_craft.getProcedures('export', gcodeText)
    gcodeText = skeinforge_craft.getChainTextFromProcedures(
        fileName, procedures[:-1], gcodeText)
    if gcodeText == '':
        return
    skeinforge_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.')
    Filehandle = open('report.txt', 'a')
    Filehandle.write('It took ' + str(int(round(time.time() - startTime))) +
                     ' seconds to export the file.')
    Filehandle.close()
Beispiel #7
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 )
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 #9
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 #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 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 #12
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 #13
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(
         'creation', 'skeinforge')  # GCode formatted comment
     absoluteFilePathUntilDot = os.path.abspath(
         __file__)[:os.path.abspath(__file__).rfind('.')]
     if absoluteFilePathUntilDot == '/home/enrique/Desktop/backup/babbleold/script/reprap/fabmetheus/skeinforge_application/skeinforge_plugins/craft_plugins/preface':  #is this script on Enrique's computer?
         gcodec.writeFileText(
             gcodec.getVersionFileName(),
             date.today().isoformat().replace('-', '.')[2:])
     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 = skeinforge_profile.getCraftTypeName()
     self.distanceFeedRate.addTagBracketedLine('craftTypeName',
                                               craftTypeName)
     self.distanceFeedRate.addTagBracketedLine(
         'decimalPlacesCarried', self.distanceFeedRate.decimalPlacesCarried)
     layerThickness = float(
         self.svgReader.sliceDictionary['layerThickness'])
     self.distanceFeedRate.addTagBracketedLine(
         'layerThickness', self.distanceFeedRate.getRounded(layerThickness))
     if self.prefaceRepository.meta.value:
         self.distanceFeedRate.addTagBracketedLine(
             'meta', self.prefaceRepository.meta.value)
     perimeterWidth = float(
         self.svgReader.sliceDictionary['perimeterWidth'])
     self.distanceFeedRate.addTagBracketedLine(
         'perimeterWidth', self.distanceFeedRate.getRounded(perimeterWidth))
     self.distanceFeedRate.addTagBracketedLine(
         'profileName', skeinforge_profile.getProfileName(craftTypeName))
     self.distanceFeedRate.addTagBracketedLine(
         'procedureDone', self.svgReader.sliceDictionary['procedureDone'])
     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 #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 %s to carve the file.' % euclidean.getDurationString( time.time() - startTime ) )
	settings.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 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 #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 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)
	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__, os.path.join('templates', 'canvas_template.svg') )
		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
		svgViewer = self.svgViewer.value
		if svgViewer == '':
			return
		if svgViewer == 'webbrowser':
			settings.openWebPage( svgFileName )
			return
		svgFilePath = '"' + os.path.normpath( svgFileName ) + '"' # " to send in file name with spaces
		shellCommand = svgViewer + ' ' + 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.' % svgViewer )
				print('If so, try installing the %s program or look for another svg viewer, like Netscape which can be found at:' % svgViewer )
				print('http://www.netscape.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.' % ( svgViewer, fileExtension ) )
			print('Try installing the %s program or look for another one, like Image Magick which can be found at:' % svgViewer )
			print('http://www.imagemagick.org/script/index.php')
	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__, os.path.join( 'templates', 'canvas_template.svg' ) )
		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 #21
0
	def writeOutput( self, fileName = ''):
		"Cleave a GNU Triangulated Surface file.  If no fileName is specified, cleave the first GNU Triangulated Surface file in this folder."
		startTime = time.time()
		print('File ' + gcodec.getSummarizedFileName(fileName) + ' is being cleaved.')
		repository = CleaveRepository()
		settings.getReadRepository(repository)
		cleaveGcode = self.getCraftedText( fileName, '', repository )
		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 %s to cleave the file.' % euclidean.getDurationString( time.time() - startTime ) )
		settings.openSVGPage( suffixFileName, repository.svgViewer.value )
Beispiel #22
0
def writeOutput( fileName = '' ):
	"Export a gcode linear move file."
	fileName = fabmetheus_interpret.getFirstTranslatorFileNameUnmodified( fileName )
	if fileName == '':
		return
	exportRepository = ExportRepository()
	settings.getReadRepository( exportRepository )
	startTime = time.time()
	print( 'File ' + gcodec.getSummarizedFileName( fileName ) + ' is being chain exported.' )
	Filehandle = open ('report.txt', 'w')
	Filehandle.write ('File ' + gcodec.getSummarizedFileName( fileName ) + ' is being chain exported.\n')
	Filehandle.close ()
	suffixFileName = fileName[ : fileName.rfind( '.' ) ] + '_export.' + exportRepository.fileExtension.value
	gcodeText = gcodec.getGcodeFileText( fileName, '' )
	procedures = skeinforge_craft.getProcedures( 'export', gcodeText )
	gcodeText = skeinforge_craft.getChainTextFromProcedures( fileName, procedures[ : - 1 ], gcodeText )
	if gcodeText == '':
		return
	skeinforge_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.' )
	Filehandle = open ('report.txt', 'a')
	Filehandle.write ('It took '+ str( int( round( time.time() - startTime ) ) )+' seconds to export the file.')
	Filehandle.close ()
def getWindowAnalyzeFileGivenText( fileName, gcodeText, repository = None ):
	"Write scalable vector graphics for a gcode file given the settings."
	if gcodeText == '':
		return None
	if repository == None:
		repository = settings.getReadRepository( VectorwriteRepository() )
	startTime = time.time()
	vectorwriteGcode = VectorwriteSkein().getCarvedSVG( fileName, gcodeText, repository )
	if vectorwriteGcode == '':
		return None
	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 %s to vectorwrite the file.' % euclidean.getDurationString( time.time() - startTime ) )
	settings.openSVGPage( suffixFileName, repository.svgViewer.value )
Beispiel #24
0
def getWindowAnalyzeFileGivenText( fileName, gcodeText, repository = None ):
	"Write scalable vector graphics for a gcode file given the settings."
	if gcodeText == '':
		return None
	if repository == None:
		repository = settings.getReadRepository( VectorwriteRepository() )
	startTime = time.time()
	vectorwriteGcode = VectorwriteSkein().getCarvedSVG( fileName, gcodeText, repository )
	if vectorwriteGcode == '':
		return None
	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 %s to vectorwrite the file.' % euclidean.getDurationString( time.time() - startTime ) )
	settings.openSVGPage( suffixFileName, repository.svgViewer.value )
Beispiel #25
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().getCarvedSVG(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 %s to vectorwrite the file." % euclidean.getDurationString(time.time() - startTime))
    settings.openWebPage(suffixFileName)
Beispiel #26
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 %s seconds to craft the file.' % int( time.time() - startTime ) )
	skeinforge_analyze.writeOutput( suffixFileName, craftText )
Beispiel #27
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 #28
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()
	fileNameSuffix = fileName[ : fileName.rfind('.') ] + '_' + procedure + '.gcode'
	craftText = getChainText( fileName, procedure )
	if craftText == '':
		return
	gcodec.writeFileText( fileNameSuffix, craftText )
	print('')
	print('The %s tool has created the file:' % procedure )
	print( fileNameSuffix )
	print('')
	print('It took %s to craft the file.' % euclidean.getDurationString( time.time() - startTime ) )
	skeinforge_analyze.writeOutput( fileName, fileNameSuffix, craftText )
Beispiel #29
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."
    startTime = time.time()
    print('File ' + gcodec.getSummarizedFileName(fileName) +
          ' is being chopped.')
    repository = ChopRepository()
    settings.getReadRepository(repository)
    chopGcode = getCraftedText(fileName, '', repository)
    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 %s to chop the file.' %
          euclidean.getDurationString(time.time() - startTime))
    settings.openSVGPage(suffixFileName, repository.svgViewer.value)
def interpretFile( fileName ):
	"Get file interpretion."
	startTime = time.time()
	pluginModule = getInterpretPlugin( fileName )
	if pluginModule == None:
		return ''
	carving = pluginModule.getCarving( fileName )
	interpretGcode = str( carving )
	if interpretGcode == '':
		return
	repository = settings.getReadRepository( InterpretRepository() )
	if repository.printInterpretion.value:
		print( interpretGcode )
	suffixFileName = fileName[ : fileName.rfind( '.' ) ] + '_interpret.' + carving.getInterpretationSuffix()
	suffixDirectoryName = os.path.dirname( suffixFileName )
	suffixReplacedBaseName = os.path.basename( suffixFileName ).replace( ' ', '_' )
	suffixFileName = os.path.join( suffixDirectoryName, suffixReplacedBaseName )
	gcodec.writeFileText( suffixFileName, interpretGcode )
	print( 'The interpret file is saved as ' + gcodec.getSummarizedFileName( suffixFileName ) )
	print( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to interpret the file.' )
Beispiel #31
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( fabmetheus_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 #32
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 #33
0
def writeXMLElement(fileNames, target, xmlElement):
	"Write target."
	object = target.object
	if object == None:
		print('Warning, writeTarget in write could not get object for:')
		print(xmlElement)
		return
	fileNameRoot = evaluate.getEvaluatedStringDefault('', 'name', target)
	fileNameRoot = evaluate.getEvaluatedStringDefault(fileNameRoot, 'id', target)
	fileNameRoot = evaluate.getEvaluatedStringDefault(fileNameRoot, 'file', xmlElement)
	fileNameRoot += evaluate.getEvaluatedStringDefault('', 'suffix', xmlElement)
	extension = evaluate.getEvaluatedStringDefault(object.getFabricationExtension(), 'extension', xmlElement)
	fileName = '%s.%s' % (fileNameRoot, extension)
	suffixIndex = 1
	while fileName in fileNames:
		fileName = '%s_%s.%s' % (fileNameRoot, suffixIndex, extension)
		suffixIndex += 1
	fileNames.append(fileName)
	folderName = evaluate.getEvaluatedStringDefault('', 'folder', xmlElement)
	absoluteFolderDirectory = os.path.join(os.path.dirname(xmlElement.getRoot().parser.fileName), folderName)
	gcodec.makeDirectory(absoluteFolderDirectory)
	gcodec.writeFileText(os.path.join(absoluteFolderDirectory, fileName), object.getFabricationText())
def interpretFile(fileName):
    "Get file interpretion."
    startTime = time.time()
    pluginModule = getInterpretPlugin(fileName)
    if pluginModule == None:
        return ''
    carving = pluginModule.getCarving(fileName)
    interpretGcode = str(carving)
    if interpretGcode == '':
        return
    repository = settings.getReadRepository(InterpretRepository())
    if repository.printInterpretion.value:
        print(interpretGcode)
    suffixFileName = fileName[:fileName.rfind(
        '.')] + '_interpret.' + carving.getInterpretationSuffix()
    suffixDirectoryName = os.path.dirname(suffixFileName)
    suffixReplacedBaseName = os.path.basename(suffixFileName).replace(' ', '_')
    suffixFileName = os.path.join(suffixDirectoryName, suffixReplacedBaseName)
    gcodec.writeFileText(suffixFileName, interpretGcode)
    print('The interpret file is saved as ' +
          gcodec.getSummarizedFileName(suffixFileName))
    print('It took ' + str(int(round(time.time() - startTime))) +
          ' seconds to interpret the file.')
Beispiel #35
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
        "BFB CODE 1st INITIALIZATION OF EXTRUDERS --------------------------------------------------------------------------------------------"
        self.bfbclass = bfb.BfbRepository()
        self.bfbclass = settings.getReadRepository(self.bfbclass)
        self.raftclass = raft.RaftRepository()
        self.raftclass = settings.getReadRepository(self.raftclass)
        self.secondHeadPrimeRev = chan(self.bfbclass.secondHeadPrimeRev.value,
                                       6400)
        self.secondHeadPrimeSpeed = chan(
            self.bfbclass.secondHeadPrimeSpeed.value, 10)
        self.secondHeadPrintRev = chan(self.bfbclass.secondHeadPrintRev.value,
                                       6400)
        self.secondHeadPrintPrime = chan(
            self.bfbclass.secondHeadPrintPrime.value, 6400)
        self.firstHeadPrimeRev = chan(self.bfbclass.firstHeadPrimeRev.value,
                                      6400)
        self.firsHeadPrimeSpeed = chan(self.bfbclass.firsHeadPrimeSpeed.value,
                                       10)
        self.firstHeadPrintRev = chan(self.bfbclass.firstHeadPrintRev.value,
                                      6400)
        self.firstHeadPrintPrime = chan(
            self.bfbclass.firstHeadPrintPrime.value, 6400)
        self.speedclass = speed.SpeedRepository()
        self.speedclass = settings.getReadRepository(self.speedclass)
        travelfeedRateMinute = 60 * self.speedclass.travelFeedRatePerSecond.value
        version = settings.getfirmware()
        version = version[0:2]

        if self.raftclass.activateRaft.value == True:
            "use second extruder for raft"
            if self.bfbclass.useRaft.value == True:
                if version == "x1":
                    self.distanceFeedRate.addLine('#v3.00')
                    self.distanceFeedRate.addLine('G90')
                    self.distanceFeedRate.addLine('M228')
                    self.distanceFeedRate.addLine('M103')
                    self.distanceFeedRate.addLine(
                        'G92 X' + str(self.bfbclass.secondHeadOffsetX.value) +
                        ' Y' + str(self.bfbclass.secondHeadOffsetY.value) +
                        ' F' + str(travelfeedRateMinute))
                    self.distanceFeedRate.addLine('M107')
                    self.distanceFeedRate.addLine(
                        'M204 S' + str(self.bfbclass.RaftT.value))
                    self.distanceFeedRate.addLine(
                        'M552 P' + str(self.secondHeadPrimeRev) + ' S' +
                        str(self.secondHeadPrimeSpeed))
                    self.distanceFeedRate.addLine('M103 P3200 S1000')
                    self.distanceFeedRate.addLine('M543')
                    if self.bfbclass.useM227.value == True:
                        self.distanceFeedRate.addLine(
                            'M227 P' + str(self.secondHeadPrintPrime) + ' S' +
                            str(self.secondHeadPrintRev))
                if version == "x2":
                    self.distanceFeedRate.addLine('#v4.00')
                    self.distanceFeedRate.addLine('G90')
                    self.distanceFeedRate.addLine(
                        'G92 X' + str(self.bfbclass.secondHeadOffsetX.value) +
                        ' Y' + str(self.bfbclass.secondHeadOffsetY.value) +
                        ' F' + str(travelfeedRateMinute))
                    if self.bfbclass.useM227.value == True:
                        self.distanceFeedRate.addLine(
                            'M227 P' + str(self.secondHeadPrintPrime) + ' S' +
                            str(self.secondHeadPrintRev))
                    self.distanceFeedRate.addLine('M107')
                    self.distanceFeedRate.addLine(
                        'M204 S' + str(self.bfbclass.RaftT.value))
                    self.distanceFeedRate.addLine(
                        'M552 P' + str(self.secondHeadPrimeRev) + ' S' +
                        str(self.secondHeadPrimeSpeed))
                    self.distanceFeedRate.addLine('M543')
                if self.bfbclass.UseFanEx2.value == True:
                    "Turn ON FAN"
                    self.distanceFeedRate.addLine('M106')
                else:
                    "Turn OFF FAN"
                    self.distanceFeedRate.addLine('M107')

            else:
                if version == "x1":
                    "use just one extruder for raft"
                    self.distanceFeedRate.addLine('G90')
                    self.distanceFeedRate.addLine('M228')
                    self.distanceFeedRate.addLine('M103')
                    self.distanceFeedRate.addLine('M107')
                    self.distanceFeedRate.addLine(
                        'M104 S' + str(self.bfbclass.RaftT.value))
                    self.distanceFeedRate.addLine('M551 P' +
                                                  str(self.firstHeadPrimeRev) +
                                                  ' S' +
                                                  str(self.firsHeadPrimeSpeed))
                    self.distanceFeedRate.addLine('M103 P3200 S1000')
                    self.distanceFeedRate.addLine('M543')

                if version == "x2":
                    "use just one extruder for raft"
                    self.distanceFeedRate.addLine('G90')
                    self.distanceFeedRate.addLine('M107')
                    self.distanceFeedRate.addLine(
                        'M104 S' + str(self.bfbclass.RaftT.value))
                    self.distanceFeedRate.addLine('M551 P' +
                                                  str(self.firstHeadPrimeRev) +
                                                  ' S' +
                                                  str(self.firsHeadPrimeSpeed))
                    self.distanceFeedRate.addLine('M543')
                if self.bfbclass.useM227.value == True:
                    self.distanceFeedRate.addLine(
                        'M227 P' + str(self.firstHeadPrintPrime) + ' S' +
                        str(self.firstHeadPrintRev))
                if self.bfbclass.UseFanEx1.value == True:
                    "Turn ON FAN"
                    self.distanceFeedRate.addLine('M106')
                else:
                    "Turn OFF FAN"
                    self.distanceFeedRate.addLine('M107')
        else:
            if version == "x1":
                "NO RAFT"
                self.distanceFeedRate.addLine('G90')
                self.distanceFeedRate.addLine('M228')
                self.distanceFeedRate.addLine('M103')
                self.distanceFeedRate.addLine('M107')
                self.distanceFeedRate.addLine(
                    'M104 S' + str(self.bfbclass.firstWorkT.value))
                self.distanceFeedRate.addLine('M551 P' +
                                              str(self.firstHeadPrimeRev) +
                                              ' S' +
                                              str(self.firsHeadPrimeSpeed))
                self.distanceFeedRate.addLine('M103 P3200 S1000')
                self.distanceFeedRate.addLine('M543')
            if version == "x2":
                self.distanceFeedRate.addLine('G90')
                self.distanceFeedRate.addLine('M107')
                self.distanceFeedRate.addLine(
                    'M104 S' + str(self.bfbclass.firstWorkT.value))
                self.distanceFeedRate.addLine('M551 P' +
                                              str(self.firstHeadPrimeRev) +
                                              ' S' +
                                              str(self.firsHeadPrimeSpeed))
                self.distanceFeedRate.addLine('M543')
            if self.bfbclass.useM227.value == True:
                self.distanceFeedRate.addLine('M227 P' +
                                              str(self.firstHeadPrintPrime) +
                                              ' S' +
                                              str(self.firstHeadPrintRev))
            if self.bfbclass.UseFanEx1.value == True:
                "Turn ON FAN"
                self.distanceFeedRate.addLine('M106')
            else:
                "Turn OFF FAN"
                self.distanceFeedRate.addLine('M107')
        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 = skeinforge_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', skeinforge_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 #36
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
		"BFB CODE 1st INITIALIZATION OF EXTRUDERS --------------------------------------------------------------------------------------------"
		self.bfbclass = bfb.BfbRepository()
		self.bfbclass = settings.getReadRepository( self.bfbclass )
		self.raftclass = raft.RaftRepository()
		self.raftclass = settings.getReadRepository( self.raftclass )
		self.secondHeadPrimeRev = chan(self.bfbclass.secondHeadPrimeRev.value, 6400)
		self.secondHeadPrimeSpeed = chan(self.bfbclass.secondHeadPrimeSpeed.value, 10)
		self.secondHeadPrintRev = chan(self.bfbclass.secondHeadPrintRev.value, 6400)
		self.secondHeadPrintPrime = chan(self.bfbclass.secondHeadPrintPrime.value, 6400)
		self.firstHeadPrimeRev = chan(self.bfbclass.firstHeadPrimeRev.value, 6400)
		self.firsHeadPrimeSpeed = chan(self.bfbclass.firsHeadPrimeSpeed.value, 10)
		self.firstHeadPrintRev = chan(self.bfbclass.firstHeadPrintRev.value, 6400)
		self.firstHeadPrintPrime = chan(self.bfbclass.firstHeadPrintPrime.value, 6400)
		self.speedclass = speed.SpeedRepository()
		self.speedclass = settings.getReadRepository( self.speedclass )
		travelfeedRateMinute=60*self.speedclass.travelFeedRatePerSecond.value
		version=settings.getfirmware()
		version=version[0:2]
		
		
		if self.raftclass.activateRaft.value == True:
			"use second extruder for raft"
			if self.bfbclass.useRaft.value == True:
				if version == "x1":
                                        self.distanceFeedRate.addLine( '#v3.00' )
					self.distanceFeedRate.addLine( 'G90' )
					self.distanceFeedRate.addLine( 'M228' )
					self.distanceFeedRate.addLine( 'M103' )
					self.distanceFeedRate.addLine( 'G92 X'+str(self.bfbclass.secondHeadOffsetX.value)+' Y'+str(self.bfbclass.secondHeadOffsetY.value)+' F'+str(travelfeedRateMinute) )
					self.distanceFeedRate.addLine( 'M107' )
					self.distanceFeedRate.addLine( 'M204 S'+str(self.bfbclass.RaftT.value) )
					self.distanceFeedRate.addLine( 'M552 P'+str(self.secondHeadPrimeRev)+' S'+str(self.secondHeadPrimeSpeed) )
					self.distanceFeedRate.addLine( 'M103 P3200 S1000' )
					self.distanceFeedRate.addLine( 'M543' )
					if self.bfbclass.useM227.value== True:
						self.distanceFeedRate.addLine( 'M227 P'+str(self.secondHeadPrintPrime)+' S'+str(self.secondHeadPrintRev) )
				if version == "x2":
                                        self.distanceFeedRate.addLine( '#v4.00' )
					self.distanceFeedRate.addLine( 'G90' )
					self.distanceFeedRate.addLine( 'G92 X'+str(self.bfbclass.secondHeadOffsetX.value)+' Y'+str(self.bfbclass.secondHeadOffsetY.value)+' F'+str(travelfeedRateMinute) )
					if self.bfbclass.useM227.value== True:
						self.distanceFeedRate.addLine( 'M227 P'+str(self.secondHeadPrintPrime)+' S'+str(self.secondHeadPrintRev) )
					self.distanceFeedRate.addLine( 'M107' )
					self.distanceFeedRate.addLine( 'M204 S'+str(self.bfbclass.RaftT.value) )
					self.distanceFeedRate.addLine( 'M552 P'+str(self.secondHeadPrimeRev)+' S'+str(self.secondHeadPrimeSpeed) )
					self.distanceFeedRate.addLine( 'M543' )
				if self.bfbclass.UseFanEx2.value== True:
					"Turn ON FAN"
					self.distanceFeedRate.addLine( 'M106')
				else:
					"Turn OFF FAN"
					self.distanceFeedRate.addLine( 'M107')
			
			else:
				if version == "x1":
					"use just one extruder for raft"
					self.distanceFeedRate.addLine( 'G90' )
					self.distanceFeedRate.addLine( 'M228' )
					self.distanceFeedRate.addLine( 'M103' )
					self.distanceFeedRate.addLine( 'M107' )
					self.distanceFeedRate.addLine( 'M104 S'+str(self.bfbclass.RaftT.value) )
					self.distanceFeedRate.addLine( 'M551 P'+str(self.firstHeadPrimeRev)+' S'+str(self.firsHeadPrimeSpeed) )
					self.distanceFeedRate.addLine( 'M103 P3200 S1000' )
					self.distanceFeedRate.addLine( 'M543' )
					
				if version == "x2":
					"use just one extruder for raft"
					self.distanceFeedRate.addLine( 'G90' )
					self.distanceFeedRate.addLine( 'M107' )
					self.distanceFeedRate.addLine( 'M104 S'+str(self.bfbclass.RaftT.value) )
					self.distanceFeedRate.addLine( 'M551 P'+str(self.firstHeadPrimeRev)+' S'+str(self.firsHeadPrimeSpeed) )
					self.distanceFeedRate.addLine( 'M543' )
				if self.bfbclass.useM227.value== True:
						self.distanceFeedRate.addLine( 'M227 P'+str(self.firstHeadPrintPrime)+' S'+str(self.firstHeadPrintRev) )
				if self.bfbclass.UseFanEx1.value== True:
					"Turn ON FAN"
					self.distanceFeedRate.addLine( 'M106')
				else:
					"Turn OFF FAN"
					self.distanceFeedRate.addLine( 'M107')
		else:
			if version == "x1":
				"NO RAFT"
				self.distanceFeedRate.addLine( 'G90' )
				self.distanceFeedRate.addLine( 'M228' )
				self.distanceFeedRate.addLine( 'M103' )
				self.distanceFeedRate.addLine( 'M107' )
				self.distanceFeedRate.addLine( 'M104 S'+str(self.bfbclass.firstWorkT.value) )
				self.distanceFeedRate.addLine( 'M551 P'+str(self.firstHeadPrimeRev)+' S'+str(self.firsHeadPrimeSpeed) )
				self.distanceFeedRate.addLine( 'M103 P3200 S1000' )
				self.distanceFeedRate.addLine( 'M543' )
			if version == "x2":
				self.distanceFeedRate.addLine( 'G90' )
				self.distanceFeedRate.addLine( 'M107' )
				self.distanceFeedRate.addLine( 'M104 S'+str(self.bfbclass.firstWorkT.value) )
				self.distanceFeedRate.addLine( 'M551 P'+str(self.firstHeadPrimeRev)+' S'+str(self.firsHeadPrimeSpeed) )
				self.distanceFeedRate.addLine( 'M543' )
			if self.bfbclass.useM227.value== True:
				self.distanceFeedRate.addLine( 'M227 P'+str(self.firstHeadPrintPrime)+' S'+str(self.firstHeadPrintRev) )
			if self.bfbclass.UseFanEx1.value== True:
				"Turn ON FAN"
				self.distanceFeedRate.addLine( 'M106')
			else:
				"Turn OFF FAN"
				self.distanceFeedRate.addLine( 'M107')
		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 = skeinforge_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', skeinforge_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.