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=''):
    "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 #4
0
def writeOutput( fileName, gcodeText = '' ):
	"Write a skeinviewed gcode file for a skeinforge gcode file, if 'Activate Skeinview' is selected."
	skeinviewPreferences = SkeinviewPreferences()
	preferences.readPreferences( skeinviewPreferences )
	if skeinviewPreferences.activateSkeinview.value:
		if gcodeText == '':
			gcodeText = gcodec.getFileText( fileName )
		displaySkeinviewFileGivenText( gcodeText, skeinviewPreferences )
Beispiel #5
0
def writeOutput( fileName, gcodeText = '' ):
	"Write statistics for a skeinforge gcode file, if 'Write Statistics File for Skeinforge Chain' is selected."
	statisticPreferences = StatisticPreferences()
	preferences.readPreferences( statisticPreferences )
	if gcodeText == '':
		gcodeText = gcodec.getFileText( fileName )
	if statisticPreferences.activateStatistic.value:
		writeStatisticFileGivenText( fileName, gcodeText, statisticPreferences )
Beispiel #6
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.readPreferences( commentPreferences )
	if gcodeText == '':
		gcodeText = gcodec.getFileText( fileName )
	if commentPreferences.activateComment.value:
		writeCommentFileGivenText( fileName, gcodeText )
Beispiel #7
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.readPreferences(commentPreferences)
    if gcodeText == '':
        gcodeText = gcodec.getFileText(fileName)
    if commentPreferences.activateComment.value:
        writeCommentFileGivenText(fileName, gcodeText)
Beispiel #8
0
def writeOutput( fileName, gcodeText = '' ):
	"Write a beholded gcode file for a skeinforge gcode file, if 'Activate Behold' is selected."
	beholdPreferences = BeholdPreferences()
	preferences.readPreferences( beholdPreferences )
	if beholdPreferences.activateBehold.value:
		if gcodeText == '':
			gcodeText = gcodec.getFileText( fileName )
		displayBeholdFileGivenText( gcodeText, beholdPreferences )
def writeOutput( fileName, gcodeText = '' ):
	"Write scalable vector graphics for a skeinforge gcode file, if 'Write Scalable Vector Graphics for Skeinforge Chain' is selected."
	vectorwritePreferences = VectorwritePreferences()
	preferences.readPreferences( vectorwritePreferences )
	if gcodeText == '':
		gcodeText = gcodec.getFileText( fileName )
	if vectorwritePreferences.activateVectorwrite.value:
		writeVectorFileGivenText( fileName, gcodeText, vectorwritePreferences )
Beispiel #10
0
def isDirectoryPreference():
    "Determine if the directory preference is true."
    polyfilePreferences = PolyfilePreferences()
    preferences.readPreferences(polyfilePreferences)
    #	if polyfilePreferences.directoryPreference.value:
    #		print( '"Execute All Unmodified Files in a Directory" is selected, so all the unmodified files in the directory will be executed.  To only execute one file, change the preference in polyfile.' )
    #	else:
    #		print( '"Execute File" is selected, so only the opened file will be executed.  To execute all the unmodified files in the directory, change the preference in polyfile.' )
    return polyfilePreferences.directoryPreference.value
Beispiel #11
0
def isDirectoryPreference():
	"Determine if the directory preference is true."
	polyfilePreferences = PolyfilePreferences()
	preferences.readPreferences( polyfilePreferences )
#	if polyfilePreferences.directoryPreference.value:
#		print( '"Execute All Unmodified Files in a Directory" is selected, so all the unmodified files in the directory will be executed.  To only execute one file, change the preference in polyfile.' )
#	else:
#		print( '"Execute File" is selected, so only the opened file will be executed.  To execute all the unmodified files in the directory, change the preference in polyfile.' )
	return polyfilePreferences.directoryPreference.value
Beispiel #12
0
def displaySkeinviewFileGivenText( gcodeText, skeinviewPreferences = None ):
	"Display a skeinviewed gcode file for a gcode file."
	if gcodeText == '':
		return ''
	if skeinviewPreferences == None:
		skeinviewPreferences = SkeinviewPreferences()
		preferences.readPreferences( skeinviewPreferences )
	skein = SkeinviewSkein()
	skein.parseGcode( gcodeText, skeinviewPreferences )
	SkeinWindow( skein.arrowType, skeinviewPreferences.screenHorizontalInset.value, skeinviewPreferences.screenVerticalInset.value, skein.scaleSize, skein.skeinPanes )
Beispiel #13
0
def getOutput(gcodeText, binary16BytePreferences=None):
    """Get the exported version of a gcode file.  This function, isArchivable 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 binary16BytePreferences == None:
        binary16BytePreferences = Binary16BytePreferences()
        preferences.readPreferences(binary16BytePreferences)
    skein = Binary16ByteSkein()
    skein.parseGcode(gcodeText, binary16BytePreferences)
    return skein.output.getvalue()
Beispiel #14
0
def getCarveGcode(fileName, carvePreferences=None):
    "Carve a shape file."
    carving = getCarving(fileName)
    if carving == None:
        return ''
    if carvePreferences == None:
        carvePreferences = CarvePreferences()
        preferences.readPreferences(carvePreferences)
    skein = CarveSkein()
    skein.parseCarving(carvePreferences, carving, fileName)
    return skein.output.getvalue()
Beispiel #15
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.readPreferences( statisticPreferences )
	writeStatisticFileGivenText( fileName, gcodec.getFileText( fileName ), statisticPreferences )
Beispiel #16
0
def getCarveGcode(fileName, carvePreferences=None):
    "Carve a shape file."
    carving = getCarving(fileName)
    if carving == None:
        return ""
    if carvePreferences == None:
        carvePreferences = CarvePreferences()
        preferences.readPreferences(carvePreferences)
    skein = CarveSkein()
    skein.parseCarving(carvePreferences, carving, fileName)
    return skein.output.getvalue()
Beispiel #17
0
def displayBeholdFileGivenText( gcodeText, beholdPreferences = None ):
	"Display a beholded gcode file for a gcode file."
	if gcodeText == '':
		return ''
	if beholdPreferences == None:
		beholdPreferences = BeholdPreferences()
		preferences.readPreferences( beholdPreferences )
	skein = BeholdSkein()
	skein.parseGcode( gcodeText, beholdPreferences )
#	beholdPreferences.displayImmediateUpdateDialog()
	skeinWindow = SkeinWindow( beholdPreferences, skein.screenSize, skein.skeinPanes )
Beispiel #18
0
def getOutput( gcodeText, gcodeStepPreferences = None ):
	"""Get the exported version of a gcode file.  This function, isArchivable 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 gcodeStepPreferences == None:
		gcodeStepPreferences = GcodeStepPreferences()
		preferences.readPreferences( gcodeStepPreferences )
	skein = GcodeStepSkein()
	skein.parseGcode( gcodeStepPreferences, gcodeText )
	return skein.output.getvalue()
Beispiel #19
0
def getInsetGcode(gcodeText, insetPreferences=None):
    "Inset the carves of a gcode text."
    if gcodeText == '':
        return ''
    if gcodec.isProcedureDone(gcodeText, 'inset'):
        return gcodeText
    if insetPreferences == None:
        insetPreferences = InsetPreferences()
        preferences.readPreferences(insetPreferences)
    skein = InsetSkein()
    skein.parseGcode(insetPreferences, gcodeText)
    return skein.output.getvalue()
def writeVectorFile( fileName = '' ):
	"Write scalable vector graphics for a gcode file.  If no fileName is specified, write scalable vector graphics for the first gcode file in this folder."
	if fileName == '':
		unmodified = gcodec.getUnmodifiedGCodeFiles()
		if len( unmodified ) == 0:
			print( "There is no gcode file in this folder." )
			return
		fileName = unmodified[ 0 ]
	vectorwritePreferences = VectorwritePreferences()
	preferences.readPreferences( vectorwritePreferences )
	gcodeText = gcodec.getFileText( fileName )
	writeVectorFileGivenText( fileName, gcodeText, vectorwritePreferences )
Beispiel #21
0
def getInsetGcode( gcodeText, insetPreferences = None ):
	"Inset the carves of a gcode text."
	if gcodeText == '':
		return ''
	if gcodec.isProcedureDone( gcodeText, 'inset' ):
		return gcodeText
	if insetPreferences == None:
		insetPreferences = InsetPreferences()
		preferences.readPreferences( insetPreferences )
	skein = InsetSkein()
	skein.parseGcode( insetPreferences, gcodeText )
	return skein.output.getvalue()
Beispiel #22
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 #23
0
def getStretchGcode( gcodeText, stretchPreferences = None ):
	"Stretch a gcode linear move text."
	if gcodeText == '':
		return ''
	if gcodec.isProcedureDone( gcodeText, 'stretch' ):
		return gcodeText
	if stretchPreferences == None:
		stretchPreferences = StretchPreferences()
		preferences.readPreferences( stretchPreferences )
	if not stretchPreferences.activateStretch.value:
		return gcodeText
	skein = StretchSkein()
	skein.parseGcode( gcodeText, stretchPreferences )
	return skein.output.getvalue()
Beispiel #24
0
def getMultiplyGcode(gcodeText, multiplyPreferences=None):
    "Multiply a gcode linear move text."
    if gcodeText == '':
        return ''
    if gcodec.isProcedureDone(gcodeText, 'multiply'):
        return gcodeText
    if multiplyPreferences == None:
        multiplyPreferences = MultiplyPreferences()
        preferences.readPreferences(multiplyPreferences)
    if not multiplyPreferences.activateMultiply.value:
        return gcodeText
    skein = MultiplySkein()
    skein.parseGcode(gcodeText, multiplyPreferences)
    return skein.output.getvalue()
Beispiel #25
0
def getSpeedGcode(gcodeText, speedPreferences=None):
    "Speed a gcode linear move text."
    if gcodeText == "":
        return ""
    if gcodec.isProcedureDone(gcodeText, "speed"):
        return gcodeText
    if speedPreferences == None:
        speedPreferences = SpeedPreferences()
        preferences.readPreferences(speedPreferences)
    if not speedPreferences.activateSpeed.value:
        return gcodeText
    skein = SpeedSkein()
    skein.parseGcode(gcodeText, speedPreferences)
    return skein.output.getvalue()
Beispiel #26
0
def getOozebaneGcode( gcodeText, oozebanePreferences = None ):
	"Oozebane a gcode linear move text."
	if gcodeText == '':
		return ''
	if gcodec.isProcedureDone( gcodeText, 'oozebane' ):
		return gcodeText
	if oozebanePreferences == None:
		oozebanePreferences = OozebanePreferences()
		preferences.readPreferences( oozebanePreferences )
	if not oozebanePreferences.activateOozebane.value:
		return gcodeText
	skein = OozebaneSkein()
	skein.parseGcode( gcodeText, oozebanePreferences )
	return skein.output.getvalue()
Beispiel #27
0
def getTowerGcode( gcodeText, towerPreferences = None ):
	"Tower a gcode linear move text."
	if gcodeText == '':
		return ''
	if gcodec.isProcedureDone( gcodeText, 'tower' ):
		return gcodeText
	if towerPreferences == None:
		towerPreferences = TowerPreferences()
		preferences.readPreferences( towerPreferences )
	if not towerPreferences.activateTower.value:
		return gcodeText
	skein = TowerSkein()
	skein.parseGcode( gcodeText, towerPreferences )
	return skein.output.getvalue()
Beispiel #28
0
def getCoolGcode( gcodeText, coolPreferences = None ):
	"Cool a gcode linear move text."
	if gcodeText == '':
		return ''
	if gcodec.isProcedureDone( gcodeText, 'cool' ):
		return gcodeText
	if coolPreferences == None:
		coolPreferences = CoolPreferences()
		preferences.readPreferences( coolPreferences )
	if not coolPreferences.activateCool.value:
		return gcodeText
	skein = CoolSkein()
	skein.parseGcode( gcodeText, coolPreferences )
	return skein.output.getvalue()
Beispiel #29
0
def getSpeedGcode(gcodeText, speedPreferences=None):
    "Speed a gcode linear move text."
    if gcodeText == '':
        return ''
    if gcodec.isProcedureDone(gcodeText, 'speed'):
        return gcodeText
    if speedPreferences == None:
        speedPreferences = SpeedPreferences()
        preferences.readPreferences(speedPreferences)
    if not speedPreferences.activateSpeed.value:
        return gcodeText
    skein = SpeedSkein()
    skein.parseGcode(gcodeText, speedPreferences)
    return skein.output.getvalue()
Beispiel #30
0
def getWipeGcode( gcodeText, wipePreferences = None ):
	"Wipe a gcode linear move text."
	if gcodeText == '':
		return ''
	if gcodec.isProcedureDone( gcodeText, 'wipe' ):
		return gcodeText
	if wipePreferences == None:
		wipePreferences = WipePreferences()
		preferences.readPreferences( wipePreferences )
	if not wipePreferences.activateWipe.value:
		return gcodeText
	skein = WipeSkein()
	skein.parseGcode( gcodeText, wipePreferences )
	return skein.output.getvalue()
Beispiel #31
0
def getHopGcode(gcodeText, hopPreferences=None):
    "Hop a gcode linear move text."
    if gcodeText == '':
        return ''
    if gcodec.isProcedureDone(gcodeText, 'hop'):
        return gcodeText
    if hopPreferences == None:
        hopPreferences = HopPreferences()
        preferences.readPreferences(hopPreferences)
    if not hopPreferences.activateHop.value:
        return gcodeText
    skein = HopSkein()
    skein.parseGcode(gcodeText, hopPreferences)
    return skein.output.getvalue()
Beispiel #32
0
def getExportGcode(gcodeText, exportPreferences=None):
    "Export a gcode linear move text."
    if gcodeText == '':
        return ''
    if gcodec.isProcedureDone(gcodeText, 'export'):
        return gcodeText
    if exportPreferences == None:
        exportPreferences = ExportPreferences()
        preferences.readPreferences(exportPreferences)
    if not exportPreferences.activateExport.value:
        return gcodeText
    skein = ExportSkein()
    skein.parseGcode(exportPreferences, gcodeText)
    return skein.output.getvalue()
Beispiel #33
0
def getUnpauseGcode(gcodeText, unpausePreferences=None):
    "Unpause a gcode linear move text."
    if gcodeText == '':
        return ''
    if gcodec.isProcedureDone(gcodeText, 'unpause'):
        return gcodeText
    if unpausePreferences == None:
        unpausePreferences = UnpausePreferences()
        preferences.readPreferences(unpausePreferences)
    if not unpausePreferences.activateUnpause.value:
        return gcodeText
    skein = UnpauseSkein()
    skein.parseGcode(unpausePreferences, gcodeText)
    return skein.output.getvalue()
Beispiel #34
0
def getUnpauseGcode( gcodeText, unpausePreferences = None ):
	"Unpause a gcode linear move text."
	if gcodeText == '':
		return ''
	if gcodec.isProcedureDone( gcodeText, 'unpause' ):
		return gcodeText
	if unpausePreferences == None:
		unpausePreferences = UnpausePreferences()
		preferences.readPreferences( unpausePreferences )
	if not unpausePreferences.activateUnpause.value:
		return gcodeText
	skein = UnpauseSkein()
	skein.parseGcode( unpausePreferences, gcodeText )
	return skein.output.getvalue()
Beispiel #35
0
def getRaftGcode( gcodeText, raftPreferences = None ):
	"Raft a gcode linear move text."
	if gcodeText == '':
		return ''
	if gcodec.isProcedureDone( gcodeText, 'raft' ):
		return gcodeText
	if raftPreferences == None:
		raftPreferences = RaftPreferences()
		preferences.readPreferences( raftPreferences )
	if not raftPreferences.activateRaft.value:
		return gcodeText
	skein = RaftSkein()
	skein.parseGcode( gcodeText, raftPreferences )
	return skein.output.getvalue()
Beispiel #36
0
def getExportGcode( gcodeText, exportPreferences = None ):
	"Export a gcode linear move text."
	if gcodeText == '':
		return ''
	if gcodec.isProcedureDone( gcodeText, 'export' ):
		return gcodeText
	if exportPreferences == None:
		exportPreferences = ExportPreferences()
		preferences.readPreferences( exportPreferences )
	if not exportPreferences.activateExport.value:
		return gcodeText
	skein = ExportSkein()
	skein.parseGcode( exportPreferences, gcodeText )
	return skein.output.getvalue()
Beispiel #37
0
def getClipGcode( gcodeText, loopTailorPreferences = None ):
	"Clip a gcode linear move text."
	if gcodeText == '':
		return ''
	if gcodec.isProcedureDone( gcodeText, 'clip' ):
		return gcodeText
	if loopTailorPreferences == None:
		loopTailorPreferences = ClipPreferences()
		preferences.readPreferences( loopTailorPreferences )
	if not loopTailorPreferences.activateClip.value:
		return gcodeText
	skein = ClipSkein()
	skein.parseGcode( gcodeText, loopTailorPreferences )
	return skein.output.getvalue()
Beispiel #38
0
def getCombGcode(gcodeText, combPreferences=None):
    "Comb a gcode linear move text."
    if gcodeText == '':
        return ''
    if gcodec.isProcedureDone(gcodeText, 'comb'):
        return gcodeText
    if combPreferences == None:
        combPreferences = CombPreferences()
        preferences.readPreferences(combPreferences)
    if not combPreferences.activateComb.value:
        return gcodeText
    skein = CombSkein()
    skein.parseGcode(combPreferences, gcodeText)
    return skein.output.getvalue()
Beispiel #39
0
def getHopGcode( gcodeText, hopPreferences = None ):
	"Hop a gcode linear move text."
	if gcodeText == '':
		return ''
	if gcodec.isProcedureDone( gcodeText, 'hop' ):
		return gcodeText
	if hopPreferences == None:
		hopPreferences = HopPreferences()
		preferences.readPreferences( hopPreferences )
	if not hopPreferences.activateHop.value:
		return gcodeText
	skein = HopSkein()
	skein.parseGcode( gcodeText, hopPreferences )
	return skein.output.getvalue()
Beispiel #40
0
def getWipeGcode(gcodeText, wipePreferences=None):
    "Wipe a gcode linear move text."
    if gcodeText == '':
        return ''
    if gcodec.isProcedureDone(gcodeText, 'wipe'):
        return gcodeText
    if wipePreferences == None:
        wipePreferences = WipePreferences()
        preferences.readPreferences(wipePreferences)
    if not wipePreferences.activateWipe.value:
        return gcodeText
    skein = WipeSkein()
    skein.parseGcode(gcodeText, wipePreferences)
    return skein.output.getvalue()
Beispiel #41
0
def getStretchGcode(gcodeText, stretchPreferences=None):
    "Stretch a gcode linear move text."
    if gcodeText == '':
        return ''
    if gcodec.isProcedureDone(gcodeText, 'stretch'):
        return gcodeText
    if stretchPreferences == None:
        stretchPreferences = StretchPreferences()
        preferences.readPreferences(stretchPreferences)
    if not stretchPreferences.activateStretch.value:
        return gcodeText
    skein = StretchSkein()
    skein.parseGcode(gcodeText, stretchPreferences)
    return skein.output.getvalue()
Beispiel #42
0
def getMultiplyGcode( gcodeText, multiplyPreferences = None ):
	"Multiply a gcode linear move text."
	if gcodeText == '':
		return ''
	if gcodec.isProcedureDone( gcodeText, 'multiply' ):
		return gcodeText
	if multiplyPreferences == None:
		multiplyPreferences = MultiplyPreferences()
		preferences.readPreferences( multiplyPreferences )
	if not multiplyPreferences.activateMultiply.value:
		return gcodeText
	skein = MultiplySkein()
	skein.parseGcode( gcodeText, multiplyPreferences )
	return skein.output.getvalue()
Beispiel #43
0
def getTwitterbotGcode( gcodeText, fileName, twitterbotPreferences = None ):
	"Add Twitterbot M-code to a gcode text."
	if gcodeText == '':
		return ''
	if gcodec.isProcedureDone( gcodeText, 'twitterbot' ):
		return gcodeText
	if twitterbotPreferences == None:
		twitterbotPreferences = TwitterbotPreferences()
		preferences.readPreferences( twitterbotPreferences )
	if not twitterbotPreferences.activateTwitterbot.value:
		return gcodeText
	skein = TwitterbotSkein()
	skein.setGcodeFilePathAndName( fileName )
	skein.parseGcode( gcodeText, twitterbotPreferences )
	return skein.output.getvalue()
Beispiel #44
0
def getRaftlessGcode(gcodeText, raftlessPreferences=None):
    "Raftless a gcode linear move text."
    if gcodec.isProcedureDone(gcodeText, 'raft'):
        print('The gcode already contains a raft. Skipping raftless tool.')
        return gcodeText
    if gcodec.isProcedureDone(gcodeText, 'raftless'):
        return gcodeText
    if raftlessPreferences == None:
        raftlessPreferences = RaftlessPreferences()
        preferences.readPreferences(raftlessPreferences)
    if not raftlessPreferences.activateRaftless.value:
        return gcodeText
    skein = RaftlessSkein()
    skein.parseGcode(gcodeText, raftlessPreferences)
    return skein.output.getvalue()
Beispiel #45
0
def arcRadiusFile( fileName = '' ):
	"Fillet a gcode linear move file into a helical radius move file.  If no fileName is specified, arc radius the first unmodified gcode file in this folder."
	if fileName == '':
		unmodified = gcodec.getUnmodifiedGCodeFiles()
		if len( unmodified ) == 0:
			print( "There are no unmodified gcode files in this folder." )
			return
		fileName = unmodified[ 0 ]
	filletPreferences = FilletPreferences()
	preferences.readPreferences( filletPreferences )
	print( 'File ' + gcodec.getSummarizedFilename( fileName ) + ' is being filleted into arc radiuses.' )
	gcodeText = gcodec.getFileText( fileName )
	if gcodeText == '':
		return
	gcodec.writeFileMessageSuffix( fileName, getArcRadiusGcode( filletPreferences, gcodeText ), 'The arc radius file is saved as ', '_fillet' )
Beispiel #46
0
def bevelFile( fileName = '' ):
	"Bevel a gcode linear move file.  If no fileName is specified, bevel the first unmodified gcode file in this folder."
	if fileName == '':
		unmodified = gcodec.getUnmodifiedGCodeFiles()
		if len( unmodified ) == 0:
			print( "There are no unmodified gcode files in this folder." )
			return
		fileName = unmodified[ 0 ]
	filletPreferences = FilletPreferences()
	preferences.readPreferences( filletPreferences )
	print( 'File ' + gcodec.getSummarizedFilename( fileName ) + ' is being beveled.' )
	gcodeText = gcodec.getFileText( fileName )
	if gcodeText == '':
		return
	gcodec.writeFileMessageSuffix( fileName, getBevelGcode( filletPreferences, gcodeText ), 'The beveled file is saved as ', '_fillet' )
Beispiel #47
0
def getRaftlessGcode( gcodeText, raftlessPreferences = None ):
	"Raftless a gcode linear move text."
	if gcodec.isProcedureDone( gcodeText, 'raft' ):
		print( 'The gcode already contains a raft. Skipping raftless tool.' )
		return gcodeText
	if gcodec.isProcedureDone( gcodeText, 'raftless' ):
		return gcodeText
	if raftlessPreferences == None:
		raftlessPreferences = RaftlessPreferences()
		preferences.readPreferences( raftlessPreferences )
	if not raftlessPreferences.activateRaftless.value:
		return gcodeText
	skein = RaftlessSkein()
	skein.parseGcode( gcodeText, raftlessPreferences )
	return skein.output.getvalue()
Beispiel #48
0
def writeOutput(fileName='', gcodeText=''):
    "Write the exported version of a gcode file.  This function, getOutput and isArchivable are the only necessary functions in a skeinforge export plugin."
    if fileName == '':
        unmodified = interpret.getGNUTranslatorFilesUnmodified()
        if len(unmodified) == 0:
            print("There are no unmodified gcode files in this folder.")
            return
        fileName = unmodified[0]
    binary16BytePreferences = Binary16BytePreferences()
    preferences.readPreferences(binary16BytePreferences)
    gcodeText = gcodec.getGcodeFileText(fileName, gcodeText)
    skeinOutput = getOutput(gcodeText, binary16BytePreferences)
    suffixFilename = fileName[:fileName.rfind(
        '.')] + '_export.' + binary16BytePreferences.fileExtension.value
    writeFileText(suffixFilename, skeinOutput)
    print('The converted file is saved as ' +
          getSummarizedFilename(suffixFilename))
Beispiel #49
0
def getFilletGcode( gcodeText, filletPreferences = None ):
	"Fillet a gcode linear move text."
	if gcodeText == '':
		return ''
	if gcodec.isProcedureDone( gcodeText, 'fillet' ):
		return gcodeText
	if filletPreferences == None:
		filletPreferences = FilletPreferences()
		preferences.readPreferences( filletPreferences )
	if not filletPreferences.activateFillet.value:
		return gcodeText
	if filletPreferences.arcPoint.value:
		return getArcPointGcode( filletPreferences, gcodeText )
	elif filletPreferences.arcRadius.value:
		return getArcRadiusGcode( filletPreferences, gcodeText )
	elif filletPreferences.arcSegment.value:
		return getArcSegmentGcode( filletPreferences, gcodeText )
	elif filletPreferences.bevel.value:
		return getBevelGcode( filletPreferences, gcodeText )
	return gcodeText
Beispiel #50
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.' )