diff --git a/patches/41 b/patches/41 index 805a1b9..0ae342f 100644 --- a/patches/41 +++ b/patches/41 @@ -345,10 +345,131 @@ diff -r -x'*.pyc' -N -u ori/41/skeinforge_application/skeinforge_plugins/craft_p self.isExtruderActive = True elif firstWord == 'M103': self.addLinearMoveExtrusionDistanceLine( - self.repository.retractionDistance.value ) +diff -r -x'*.pyc' -N -u ori/41/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_tiny.py target/SF41/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_tiny.py +--- ori/41/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_tiny.py 1970-01-01 01:00:00.000000000 +0100 ++++ target/SF41/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_tiny.py 2011-12-15 16:23:55.000000000 +0100 +@@ -0,0 +1,117 @@ ++""" ++This page is in the table of contents. ++Gcode_tiny is an export plugin to remove the comments and the redundant z and feed rate parameters from a gcode file. ++ ++An export plugin is a script in the export_plugins folder which has the getOutput function, the globalIsReplaceable variable and if it's output is not replaceable, the writeOutput function. It is meant to be run from the export tool. To ensure that the plugin works on platforms which do not handle file capitalization properly, give the plugin a lower case name. ++ ++The getOutput function of this script takes a gcode text and returns that text without comments and redundant z and feed rate parameters. The writeOutput function of this script takes a gcode text and writes that text without comments and redundant z and feed rate parameters to a file. ++ ++Many of the functions in this script are copied from gcodec in skeinforge_utilities. They are copied rather than imported so developers making new plugins do not have to learn about gcodec, the code here is all they need to learn. ++ ++""" ++ ++from __future__ import absolute_import ++import cStringIO ++import os ++ ++ ++__author__ = 'Enrique Perez (perez_enrique@yahoo.com)' ++__date__ = '$Date: 2008/21/04 $' ++__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html' ++ ++ ++# This is true if the output is text and false if it is binary." ++globalIsReplaceable = True ++ ++ ++def getOutput(gcodeText): ++ 'Get the exported version of a gcode file.' ++ return GcodeTinySkein().getCraftedGcode(gcodeText) ++ ++def getSplitLineBeforeBracketSemicolon(line): ++ "Get the split line before a bracket or semicolon." ++ bracketSemicolonIndex = min( line.find(';'), line.find('(') ) ++ if bracketSemicolonIndex < 0: ++ return line.split() ++ return line[ : bracketSemicolonIndex ].split() ++ ++def getStringFromCharacterSplitLine(character, splitLine): ++ "Get the string after the first occurence of the character in the split line." ++ indexOfCharacter = getIndexOfStartingWithSecond(character, splitLine) ++ if indexOfCharacter < 0: ++ return None ++ return splitLine[indexOfCharacter][1 :] ++ ++def getSummarizedFileName(fileName): ++ "Get the fileName basename if the file is in the current working directory, otherwise return the original full name." ++ if os.getcwd() == os.path.dirname(fileName): ++ return os.path.basename(fileName) ++ return fileName ++ ++def getTextLines(text): ++ "Get the all the lines of text of a text." ++ return text.replace('\r', '\n').split('\n') ++ ++def getIndexOfStartingWithSecond(letter, splitLine): ++ "Get index of the first occurence of the given letter in the split line, starting with the second word. Return - 1 if letter is not found" ++ for wordIndex in xrange( 1, len(splitLine) ): ++ word = splitLine[ wordIndex ] ++ firstLetter = word[0] ++ if firstLetter == letter: ++ return wordIndex ++ return - 1 ++ ++ ++class GcodeTinySkein: ++ "A class to remove redundant z and feed rate parameters from a skein of extrusions." ++ "Also remove spaces and minimize the exported numbers, this will create GCode which not every tool will understand." ++ def __init__(self): ++ self.lastFeedRateString = None ++ self.lastZString = None ++ self.output = cStringIO.StringIO() ++ ++ def getCraftedGcode( self, gcodeText ): ++ "Parse gcode text and store the gcode." ++ lines = getTextLines(gcodeText) ++ for line in lines: ++ self.parseLine(line) ++ return self.output.getvalue() ++ ++ def fixStringNumber(self, s): ++ if s == None: ++ return None ++ return str(float(s)) ++ ++ def parseLine(self, line): ++ "Parse a gcode line." ++ splitLine = getSplitLineBeforeBracketSemicolon(line) ++ if len(splitLine) < 1: ++ return ++ firstWord = splitLine[0] ++ if len(firstWord) < 1: ++ return ++ if firstWord[0] == '(': ++ return ++ if firstWord != 'G1': ++ self.output.write(line + '\n') ++ return ++ eString = self.fixStringNumber(getStringFromCharacterSplitLine('E', splitLine )) ++ xString = self.fixStringNumber(getStringFromCharacterSplitLine('X', splitLine )) ++ yString = self.fixStringNumber(getStringFromCharacterSplitLine('Y', splitLine )) ++ zString = self.fixStringNumber(getStringFromCharacterSplitLine('Z', splitLine )) ++ feedRateString = self.fixStringNumber(getStringFromCharacterSplitLine('F', splitLine )) ++ self.output.write('G1') ++ if xString != None: ++ self.output.write('X' + xString ) ++ if yString != None: ++ self.output.write('Y' + yString ) ++ if zString != None and zString != self.lastZString: ++ self.output.write('Z' + zString ) ++ if feedRateString != None and feedRateString != self.lastFeedRateString: ++ self.output.write('F' + feedRateString ) ++ if eString != None: ++ self.output.write('E' + eString ) ++ self.lastFeedRateString = feedRateString ++ self.lastZString = zString ++ self.output.write('\n') ++ diff -r -x'*.pyc' -N -u ori/41/skeinforge_application/skeinforge_plugins/craft_plugins/export.py target/SF41/skeinforge_application/skeinforge_plugins/craft_plugins/export.py --- ori/41/skeinforge_application/skeinforge_plugins/craft_plugins/export.py 2011-02-09 08:28:22.000000000 +0100 -+++ target/SF41/skeinforge_application/skeinforge_plugins/craft_plugins/export.py 2011-12-15 11:43:14.000000000 +0100 -@@ -214,7 +214,7 @@ ++++ target/SF41/skeinforge_application/skeinforge_plugins/craft_plugins/export.py 2011-12-15 16:14:40.000000000 +0100 +@@ -214,17 +214,20 @@ self.exportLabel = settings.LabelDisplay().getFromName('Export Operations: ', self) self.exportPlugins = [] exportLatentStringVar = settings.LatentStringVar() @@ -357,12 +478,18 @@ diff -r -x'*.pyc' -N -u ori/41/skeinforge_application/skeinforge_plugins/craft_p self.doNotChangeOutput.directoryPath = None allExportPluginFileNames = exportPluginFileNames + exportStaticPluginFileNames for exportPluginFileName in allExportPluginFileNames: -@@ -224,7 +224,7 @@ - exportPlugin = settings.RadioCapitalizedButton().getFromPath(exportLatentStringVar, exportPluginFileName, path, self, False) + exportPlugin = None ++ default = False ++ if exportPluginFileName == "gcode_small": ++ default = True + if exportPluginFileName in exportPluginFileNames: + path = os.path.join(exportPluginsFolderPath, exportPluginFileName) +- exportPlugin = settings.RadioCapitalizedButton().getFromPath(exportLatentStringVar, exportPluginFileName, path, self, False) ++ exportPlugin = settings.RadioCapitalizedButton().getFromPath(exportLatentStringVar, exportPluginFileName, path, self, default) exportPlugin.directoryPath = exportPluginsFolderPath else: - exportPlugin = settings.RadioCapitalized().getFromRadio(exportLatentStringVar, exportPluginFileName, self, False) -+ exportPlugin = settings.RadioCapitalized().getFromRadio(exportLatentStringVar, exportPluginFileName, self, True) ++ exportPlugin = settings.RadioCapitalized().getFromRadio(exportLatentStringVar, exportPluginFileName, self, default) exportPlugin.directoryPath = exportStaticDirectoryPath self.exportPlugins.append(exportPlugin) self.fileExtension = settings.StringSetting().getFromValue('File Extension:', self, 'gcode') @@ -547,7 +674,7 @@ diff -r -x'*.pyc' -N -u ori/41/skeinforge_application/skeinforge_plugins/craft_p self.coolingRate = settings.FloatSpin().getFromValue( 1.0, 'Cooling Rate (Celcius/second):', self, 20.0, 3.0 ) diff -r -x'*.pyc' -N -u ori/41/skeinforge_application/skeinforge.py target/SF41/skeinforge_application/skeinforge.py --- ori/41/skeinforge_application/skeinforge.py 2011-04-27 02:14:25.000000000 +0200 -+++ target/SF41/skeinforge_application/skeinforge.py 2011-12-15 11:43:14.000000000 +0100 ++++ target/SF41/skeinforge_application/skeinforge.py 2011-12-15 15:28:29.000000000 +0100 @@ -228,6 +228,7 @@ from skeinforge_application.skeinforge_utilities import skeinforge_profile import os @@ -564,7 +691,7 @@ diff -r -x'*.pyc' -N -u ori/41/skeinforge_application/skeinforge.py target/SF41/ class SkeinforgeRepository: -@@ -568,13 +568,35 @@ +@@ -568,13 +568,36 @@ settings.LabelDisplay().getFromName('', self) importantFileNames = ['craft', 'profile'] getRadioPluginsAddPluginGroupFrame(archive.getSkeinforgePluginsPath(), importantFileNames, getPluginFileNames(), self) @@ -598,7 +725,8 @@ diff -r -x'*.pyc' -N -u ori/41/skeinforge_application/skeinforge.py target/SF41/ + if pypyExe == False or platform.python_implementation() == "PyPy": + skeinforge_craft.writeOutput(fileName) + else: -+ os.system(pypyExe + " '" + fileName + "'"); ++ if os.system(pypyExe + " '" + fileName + "'") > 0: ++ skeinforge_craft.writeOutput(fileName) def save(self): 'Profile has been saved and profile menu should be updated.' diff --git a/patches/45 b/patches/45 index 3a9c91d..c10986e 100644 --- a/patches/45 +++ b/patches/45 @@ -192,8 +192,8 @@ diff -r -x'*.pyc' -N -u ori/45/skeinforge_application/skeinforge_plugins/craft_p self.maximumEValueBeforeReset = settings.FloatSpin().getFromValue(0.0, 'Maximum E Value before Reset (float):', self, 999999.9, 91234.0) diff -r -x'*.pyc' -N -u ori/45/skeinforge_application/skeinforge_plugins/craft_plugins/export.py target/SF45/skeinforge_application/skeinforge_plugins/craft_plugins/export.py --- ori/45/skeinforge_application/skeinforge_plugins/craft_plugins/export.py 2011-10-17 22:31:29.000000000 +0200 -+++ target/SF45/skeinforge_application/skeinforge_plugins/craft_plugins/export.py 2011-12-15 11:43:14.000000000 +0100 -@@ -339,7 +339,7 @@ ++++ target/SF45/skeinforge_application/skeinforge_plugins/craft_plugins/export.py 2011-12-15 16:15:45.000000000 +0100 +@@ -339,17 +339,20 @@ self.exportLabel = settings.LabelDisplay().getFromName('Export Operations: ', self) self.exportPlugins = [] exportLatentStringVar = settings.LatentStringVar() @@ -202,12 +202,18 @@ diff -r -x'*.pyc' -N -u ori/45/skeinforge_application/skeinforge_plugins/craft_p self.doNotChangeOutput.directoryPath = None allExportPluginFileNames = exportPluginFileNames + exportStaticPluginFileNames for exportPluginFileName in allExportPluginFileNames: -@@ -349,7 +349,7 @@ - exportPlugin = settings.RadioCapitalizedButton().getFromPath(exportLatentStringVar, exportPluginFileName, path, self, False) + exportPlugin = None ++ default = False ++ if exportPluginFileName == "gcode_small": ++ default = True + if exportPluginFileName in exportPluginFileNames: + path = os.path.join(exportPluginsFolderPath, exportPluginFileName) +- exportPlugin = settings.RadioCapitalizedButton().getFromPath(exportLatentStringVar, exportPluginFileName, path, self, False) ++ exportPlugin = settings.RadioCapitalizedButton().getFromPath(exportLatentStringVar, exportPluginFileName, path, self, default) exportPlugin.directoryPath = exportPluginsFolderPath else: - exportPlugin = settings.RadioCapitalized().getFromRadio(exportLatentStringVar, exportPluginFileName, self, False) -+ exportPlugin = settings.RadioCapitalized().getFromRadio(exportLatentStringVar, exportPluginFileName, self, True) ++ exportPlugin = settings.RadioCapitalized().getFromRadio(exportLatentStringVar, exportPluginFileName, self, default) exportPlugin.directoryPath = exportStaticDirectoryPath self.exportPlugins.append(exportPlugin) self.fileExtension = settings.StringSetting().getFromValue('File Extension:', self, 'gcode') @@ -388,7 +394,7 @@ diff -r -x'*.pyc' -N -u ori/45/skeinforge_application/skeinforge_plugins/craft_p self.coolingRate = settings.FloatSpin().getFromValue( 1.0, 'Cooling Rate (Celcius/second):', self, 20.0, 3.0 ) diff -r -x'*.pyc' -N -u ori/45/skeinforge_application/skeinforge.py target/SF45/skeinforge_application/skeinforge.py --- ori/45/skeinforge_application/skeinforge.py 2011-11-08 10:32:18.000000000 +0100 -+++ target/SF45/skeinforge_application/skeinforge.py 2011-12-15 11:43:14.000000000 +0100 ++++ target/SF45/skeinforge_application/skeinforge.py 2011-12-15 15:29:07.000000000 +0100 @@ -228,6 +228,7 @@ from skeinforge_application.skeinforge_utilities import skeinforge_profile import os @@ -405,7 +411,7 @@ diff -r -x'*.pyc' -N -u ori/45/skeinforge_application/skeinforge.py target/SF45/ class SkeinforgeRepository: -@@ -576,13 +576,35 @@ +@@ -576,13 +576,36 @@ settings.LabelDisplay().getFromName('', self) importantFileNames = ['craft', 'profile'] getRadioPluginsAddPluginGroupFrame(archive.getSkeinforgePluginsPath(), importantFileNames, getPluginFileNames(), self) @@ -439,7 +445,8 @@ diff -r -x'*.pyc' -N -u ori/45/skeinforge_application/skeinforge.py target/SF45/ + if pypyExe == False or platform.python_implementation() == "PyPy": + skeinforge_craft.writeOutput(fileName) + else: -+ os.system(pypyExe + " '" + fileName + "'"); ++ if os.system(pypyExe + " '" + fileName + "'") > 0: ++ skeinforge_craft.writeOutput(fileName) def save(self): 'Profile has been saved and profile menu should be updated.'