Esempio n. 1
0
def writeOutput( fileName, gcodeText = '' ):
	"Display a skeinviewed gcode file for a skeinforge gcode file, if 'Activate Skeinview' is selected."
	skeinviewPreferences = SkeinviewPreferences()
	preferences.getReadRepository( skeinviewPreferences )
	if skeinviewPreferences.activateSkeinview.value:
		gcodeText = gcodec.getTextIfEmpty( fileName, gcodeText )
		displayFileGivenText( fileName, gcodeText, skeinviewPreferences )
Esempio n. 2
0
def writeOutput( fileName, gcodeText = '' ):
	"Write a beholded gcode file for a skeinforge gcode file, if 'Activate Behold' is selected."
	beholdPreferences = BeholdPreferences()
	preferences.getReadRepository( beholdPreferences )
	if beholdPreferences.activateBehold.value:
		gcodeText = gcodec.getTextIfEmpty( fileName, gcodeText )
		displayFileGivenText( fileName, gcodeText, beholdPreferences )
Esempio n. 3
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.' )
Esempio n. 4
0
def writeOutput(fileName, gcodeText=""):
    "Write statistics for a skeinforge gcode file, if 'Write Statistics File for Skeinforge Chain' is selected."
    statisticPreferences = StatisticPreferences()
    preferences.getReadRepository(statisticPreferences)
    if gcodeText == "":
        gcodeText = gcodec.getFileText(fileName)
    if statisticPreferences.activateStatistic.value:
        writeStatisticFileGivenText(fileName, gcodeText, statisticPreferences)
Esempio n. 5
0
def writeOutput( fileName, gcodeText = '' ):
	"Write a commented gcode file for a skeinforge gcode file, if 'Write Commented File for Skeinforge Chain' is selected."
	commentPreferences = CommentPreferences()
	preferences.getReadRepository( commentPreferences )
	if gcodeText == '':
		gcodeText = gcodec.getFileText( fileName )
	if commentPreferences.activateComment.value:
		writeCommentFileGivenText( fileName, gcodeText )
Esempio n. 6
0
def displayFileGivenText( fileName, gcodeText, skeinviewPreferences = None ):
	"Display a gcode file in a skeinview window given the text."
	if gcodeText == '':
		return
	if skeinviewPreferences == None:
		skeinviewPreferences = SkeinviewPreferences()
		preferences.getReadRepository( skeinviewPreferences )
	skeinWindow = getWindowGivenTextPreferences( fileName, gcodeText, skeinviewPreferences )
	skeinWindow.updateDeiconify()
Esempio n. 7
0
def getCraftedTextFromFileName( fileName, carveRepository = None ):
	"Carve a shape file."
	carving = svg_codec.getCarving( fileName )
	if carving == None:
		return ''
	if carveRepository == None:
		carveRepository = CarveRepository()
		preferences.getReadRepository( carveRepository )
	return CarveSkein().getCarvedSVG( carveRepository, carving, fileName )
Esempio n. 8
0
def getOutput( gcodeText, binary16ByteRepository = None ):
	"""Get the exported version of a gcode file.  This function, and writeOutput are the only necessary functions in a skeinforge export plugin.
	If this plugin writes an output than should not be printed, an empty string should be returned."""
	if gcodeText == '':
		return ''
	if binary16ByteRepository == None:
		binary16ByteRepository = Binary16ByteRepository()
		preferences.getReadRepository( binary16ByteRepository )
	return Binary16ByteSkein().getCraftedGcode( gcodeText, binary16ByteRepository )
Esempio n. 9
0
def displayFileGivenText( fileName, gcodeText, beholdPreferences = None ):
	"Display a beholded gcode file for a gcode file."
	if gcodeText == '':
		return ''
	if beholdPreferences == None:
		beholdPreferences = BeholdPreferences()
		preferences.getReadRepository( beholdPreferences )
	skeinWindow = getWindowGivenTextPreferences( fileName, gcodeText, beholdPreferences )
	skeinWindow.updateDeiconify()
Esempio n. 10
0
def writeOutput( fileName, gcodeText = '' ):
	"Write the exported version of a gcode file.  This function, and getOutput are the only necessary functions in a skeinforge export plugin."
	binary16ByteRepository = Binary16ByteRepository()
	preferences.getReadRepository( binary16ByteRepository )
	gcodeText = gcodec.getGcodeFileText( fileName, gcodeText )
	skeinOutput = getOutput( gcodeText, binary16ByteRepository )
	suffixFilename = fileName[ : fileName.rfind( '.' ) ] + '.' + binary16ByteRepository.fileExtension.value
	writeFileText( suffixFilename, skeinOutput )
	print( 'The converted file is saved as ' + getSummarizedFilename( suffixFilename ) )
Esempio n. 11
0
def statisticFile(fileName=""):
    "Write statistics for a gcode file.  If no fileName is specified, write statistics for the first gcode file in this folder that is not modified."
    if fileName == "":
        unmodified = gcodec.getUnmodifiedGCodeFiles()
        if len(unmodified) == 0:
            print("There are no unmodified gcode files in this folder.")
            return
        fileName = unmodified[0]
    statisticPreferences = StatisticPreferences()
    preferences.getReadRepository(statisticPreferences)
    writeStatisticFileGivenText(fileName, gcodec.getFileText(fileName), statisticPreferences)
Esempio n. 12
0
def writeOutput( fileName, gcodeText = '' ):
	"Write scalable vector graphics for a skeinforge gcode file, if activate vectorwrite is selected."
	vectorwritePreferences = preferences.getReadRepository( VectorwritePreferences() )
	if not vectorwritePreferences.activateVectorwrite.value:
		return
	gcodeText = gcodec.getTextIfEmpty( fileName, gcodeText )
	writeGivenPreferences( fileName, gcodeText, vectorwritePreferences )
Esempio n. 13
0
def getCraftedTextFromText( text, prefaceRepository = None ):
	"Preface and convert an svg text."
	if gcodec.isProcedureDoneOrFileIsEmpty( text, 'preface' ):
		return text
	if prefaceRepository == None:
		prefaceRepository = preferences.getReadRepository( PrefaceRepository() )
	return PrefaceSkein().getCraftedGcode( prefaceRepository, text )
Esempio n. 14
0
def getCraftedTextFromText( gcodeText, insetRepository = None ):
	"Inset the preface gcode text."
	if gcodec.isProcedureDoneOrFileIsEmpty( gcodeText, 'inset' ):
		return gcodeText
	if insetRepository == None:
		insetRepository = preferences.getReadRepository( InsetRepository() )
	return InsetSkein().getCraftedGcode( insetRepository, gcodeText )
Esempio n. 15
0
def getCraftedTextFromText( gcodeText, homeRepository = None ):
	"Home a gcode linear move text."
	if gcodec.isProcedureDoneOrFileIsEmpty( gcodeText, 'home' ):
		return gcodeText
	if homeRepository == None:
		homeRepository = preferences.getReadRepository( HomeRepository() )
	if not homeRepository.activateHome.value:
		return gcodeText
	return HomeSkein().getCraftedGcode( gcodeText, homeRepository )
Esempio n. 16
0
def getCraftedTextFromText( gcodeText, combRepository = None ):
	"Comb a gcode linear move text."
	if gcodec.isProcedureDoneOrFileIsEmpty( gcodeText, 'comb' ):
		return gcodeText
	if combRepository == None:
		combRepository = preferences.getReadRepository( CombRepository() )
	if not combRepository.activateComb.value:
		return gcodeText
	return CombSkein().getCraftedGcode( combRepository, gcodeText )
Esempio n. 17
0
def getCraftedTextFromText( gcodeText, outsetRepository = None ):
	"Outset the preface gcode text."
	if gcodec.isProcedureDoneOrFileIsEmpty( gcodeText, 'outset' ):
		return gcodeText
	if outsetRepository == None:
		outsetRepository = preferences.getReadRepository( OutsetRepository() )
	if not outsetRepository.activateOutset.value:
		return gcodeText
	return OutsetSkein().getCraftedGcode( outsetRepository, gcodeText )
Esempio n. 18
0
def getCraftedTextFromText( gcodeText, chamberRepository = None ):
	"Chamber a gcode linear move text."
	if gcodec.isProcedureDoneOrFileIsEmpty( gcodeText, 'chamber' ):
		return gcodeText
	if chamberRepository == None:
		chamberRepository = preferences.getReadRepository( ChamberRepository() )
	if not chamberRepository.activateChamber.value:
		return gcodeText
	return ChamberSkein().getCraftedGcode( gcodeText, chamberRepository )
Esempio n. 19
0
def getCraftedTextFromText( gcodeText, unpauseRepository = None ):
	"Unpause a gcode linear move text."
	if gcodec.isProcedureDoneOrFileIsEmpty( gcodeText, 'unpause' ):
		return gcodeText
	if unpauseRepository == None:
		unpauseRepository = preferences.getReadRepository( UnpauseRepository() )
	if not unpauseRepository.activateUnpause.value:
		return gcodeText
	return UnpauseSkein().getCraftedGcode( unpauseRepository, gcodeText )
Esempio n. 20
0
def getCraftedTextFromText( gcodeText, wipeRepository = None ):
	"Wipe a gcode linear move text."
	if gcodec.isProcedureDoneOrFileIsEmpty( gcodeText, 'wipe' ):
		return gcodeText
	if wipeRepository == None:
		wipeRepository = preferences.getReadRepository( WipeRepository() )
	if not wipeRepository.activateWipe.value:
		return gcodeText
	return WipeSkein().getCraftedGcode( gcodeText, wipeRepository )
Esempio n. 21
0
def getCraftedTextFromText( gcodeText, jitterRepository = None ):
	"Jitter a gcode linear move text."
	if gcodec.isProcedureDoneOrFileIsEmpty( gcodeText, 'jitter' ):
		return gcodeText
	if jitterRepository == None:
		jitterRepository = preferences.getReadRepository( JitterRepository() )
	if not jitterRepository.activateJitter.value:
		return gcodeText
	return JitterSkein().getCraftedGcode( jitterRepository, gcodeText )
Esempio n. 22
0
def getCraftedTextFromText( gcodeText, clipRepository = None ):
	"Clip a gcode linear move text."
	if gcodec.isProcedureDoneOrFileIsEmpty( gcodeText, 'clip' ):
		return gcodeText
	if clipRepository == None:
		clipRepository = preferences.getReadRepository( ClipRepository() )
	if not clipRepository.activateClip.value:
		return gcodeText
	return ClipSkein().getCraftedGcode( clipRepository, gcodeText )
Esempio n. 23
0
def getCraftedTextFromText( gcodeText, exportRepository = None ):
	"Export a gcode linear move text."
	if gcodec.isProcedureDoneOrFileIsEmpty( gcodeText, 'export' ):
		return gcodeText
	if exportRepository == None:
		exportRepository = preferences.getReadRepository( ExportRepository() )
	if not exportRepository.activateExport.value:
		return gcodeText
	return ExportSkein().getCraftedGcode( exportRepository, gcodeText )
Esempio n. 24
0
def getCraftedTextFromText( gcodeText, oozebaneRepository = None ):
	"Oozebane a gcode linear move text."
	if gcodec.isProcedureDoneOrFileIsEmpty( gcodeText, 'oozebane' ):
		return gcodeText
	if oozebaneRepository == None:
		oozebaneRepository = preferences.getReadRepository( OozebaneRepository() )
	if not oozebaneRepository.activateOozebane.value:
		return gcodeText
	return OozebaneSkein().getCraftedGcode( gcodeText, oozebaneRepository )
Esempio n. 25
0
def getCraftedTextFromText( gcodeText, raftRepository = None ):
	"Raft a gcode linear move text."
	if gcodec.isProcedureDoneOrFileIsEmpty( gcodeText, 'raft' ):
		return gcodeText
	if raftRepository == None:
		raftRepository = preferences.getReadRepository( RaftRepository() )
	if not raftRepository.activateRaft.value:
		return gcodeText
	return RaftSkein().getCraftedGcode( gcodeText, raftRepository )
Esempio n. 26
0
def getCraftedTextFromText( gcodeText, towerRepository = None ):
	"Tower a gcode linear move text."
	if gcodec.isProcedureDoneOrFileIsEmpty( gcodeText, 'tower' ):
		return gcodeText
	if towerRepository == None:
		towerRepository = preferences.getReadRepository( TowerRepository() )
	if not towerRepository.activateTower.value:
		return gcodeText
	return TowerSkein().getCraftedGcode( gcodeText, towerRepository )
Esempio n. 27
0
def getCraftedTextFromText( gcodeText, flowRepository = None ):
	"Flow a gcode linear move text."
	if gcodec.isProcedureDoneOrFileIsEmpty( gcodeText, 'flow' ):
		return gcodeText
	if flowRepository == None:
		flowRepository = preferences.getReadRepository( FlowRepository() )
	if not flowRepository.activateFlow.value:
		return gcodeText
	return FlowSkein().getCraftedGcode( gcodeText, flowRepository )
Esempio n. 28
0
def getCraftedTextFromText( gcodeText, stretchRepository = None ):
	"Stretch a gcode linear move text."
	if gcodec.isProcedureDoneOrFileIsEmpty( gcodeText, 'stretch' ):
		return gcodeText
	if stretchRepository == None:
		stretchRepository = preferences.getReadRepository( StretchRepository() )
	if not stretchRepository.activateStretch.value:
		return gcodeText
	return StretchSkein().getCraftedGcode( gcodeText, stretchRepository )
Esempio n. 29
0
def getCraftedTextFromText( gcodeText, speedRepository = None ):
	"Speed a gcode linear move text."
	if gcodec.isProcedureDoneOrFileIsEmpty( gcodeText, 'speed' ):
		return gcodeText
	if speedRepository == None:
		speedRepository = preferences.getReadRepository( SpeedRepository() )
	if not speedRepository.activateSpeed.value:
		return gcodeText
	return SpeedSkein().getCraftedGcode( gcodeText, speedRepository )
Esempio n. 30
0
def getCraftedTextFromText( gcodeText, lashRepository = None ):
	"Get a lashed gcode linear move text from text."
	if gcodec.isProcedureDoneOrFileIsEmpty( gcodeText, 'lash' ):
		return gcodeText
	if lashRepository == None:
		lashRepository = preferences.getReadRepository( LashRepository() )
	if not lashRepository.activateLash.value:
		return gcodeText
	return LashSkein().getCraftedGcode( gcodeText, lashRepository )