Python: module fabmetheus_utilities.gcodec

fabmetheus_utilities.gcodec ($Date: 2008/21/04 $) | index /home/enrique/Desktop/backup/babbleold/script/reprap/fabmetheus/fabmetheus_utilities/gcodec.py

`Gcodec is a collection of utilities to decode and encode gcode.
To run gcodec, install python 2.x on your machine, which is avaliable from http://www.python.org/download/
Then in the folder which gcodec is in, type 'python' in a shell to run the python interpreter. Finally type 'from gcodec import *' to import this program.
Below is an example of gcodec use. This example is run in a terminal in the folder which contains gcodec and Screw Holder Bottom_export.gcode.
>>> from gcodec import *
>>> getFileText('Screw Holder Bottom_export.gcode')
'G90
G21
M103
M105
M106
M110 S60.0
M111 S30.0
M108 S210.0
M104 S235.0
G1 X0.37 Y-4.07 Z1.9 F60.0
M101
..
many lines of text
..`

Modules
`` |  |
__init__ fabmetheus_utilities.archive | cStringIO fabmetheus_utilities.euclidean | math os | sys traceback

Classes
`` |  | BoundingRectangle DistanceFeedRate
class BoundingRectangle
`` | `A class to get the corners of a gcode text.`
| Methods defined here: getFromGcodeLines(self, lines, radius) `Parse gcode text and get the minimum and maximum corners.` isPointInside(self, point) `Determine if the point is inside the bounding rectangle.` parseCorner(self, line) `Parse a gcode line and use the location to update the bounding corners.`
class DistanceFeedRate
`` | `A class to limit the z feed rate and round values.`
| Methods defined here: __init__(self) `Initialize.` addGcodeFromFeedRateThreadZ(self, feedRateMinute, thread, travelFeedRateMinute, z) `Add a thread to the output.` addGcodeFromLoop(self, loop, z) `Add the gcode loop.` addGcodeFromThreadZ(self, thread, z) `Add a thread to the output.` addGcodeMovementZ(self, point, z) `Add a movement to the output.` addGcodeMovementZWithFeedRate(self, feedRateMinute, point, z) `Add a movement to the output.` addLine(self, line) `Add a line of text and a newline to the output.` addLineCheckAlteration(self, line) `Add a line of text and a newline to the output and check to see if it is an alteration line.` addLines(self, lines) `Add lines of text to the output.` addLinesSetAbsoluteDistanceMode(self, lines) `Add lines of text to the output and ensure the absolute mode is set.` addParameter(self, firstWord, parameter) `Add the parameter.` addPerimeterBlock(self, loop, z) `Add the perimeter gcode block for the loop.` addTagBracketedLine(self, tagName, value) `Add a begin tag, value and end tag.` addTagBracketedProcedure(self, procedure) `Add a begin procedure tag, procedure and end procedure tag.` addTagRoundedLine(self, tagName, value) `Add a begin tag, rounded value and end tag.` getBoundaryLine(self, location) `Get boundary gcode line.` getFirstWordMovement(self, firstWord, location) `Get the start of the arc line.` getInfillBoundaryLine(self, location) `Get infill boundary gcode line.` getIsAlteration(self, line) `Determine if it is an alteration.` getLineWithFeedRate(self, feedRateMinute, line, splitLine) `Get the line with a feed rate.` getLineWithX(self, line, splitLine, x) `Get the line with an x.` getLineWithY(self, line, splitLine, y) `Get the line with a y.` getLineWithZ(self, line, splitLine, z) `Get the line with a z.` getLinearGcodeMovement(self, point, z) `Get a linear gcode movement.` getLinearGcodeMovementWithFeedRate(self, feedRateMinute, point, z) `Get a z limited gcode movement.` getRounded(self, number) `Get number rounded to the number of carried decimal places as a string.` parseSplitLine(self, firstWord, splitLine) `Parse gcode split line and store the parameters.`

Functions
`` |  | addLineAndNewlineIfNecessary(line, output) `Add the line and if the line does not end with a newline add a newline.` addLinesToCString(cString, lines) `Add lines which have something to cStringIO.` getArcDistance(relativeLocation, splitLine) `Get arc distance.` getDoubleAfterFirstLetter(word) `Get the double value of the word after the first letter.` getDoubleForLetter(letter, splitLine) `Get the double value of the word after the first occurence of the letter in the split line.` getDoubleFromCharacterSplitLine(character, splitLine) `Get the double value of the string after the first occurence of the character in the split line.` getDoubleFromCharacterSplitLineValue(character, splitLine, value) `Get the double value of the string after the first occurence of the character in the split line, if it does not exist return the value.` getFeedRateMinute(feedRateMinute, splitLine) `Get the feed rate per minute if the split line has a feed rate.` getFirstWord(splitLine) `Get the first word of a split line.` getFirstWordFromLine(line) `Get the first word of a line.` getFirstWordIndexReverse(firstWord, lines, startIndex) `Parse gcode in reverse order until the first word if there is one, otherwise return -1.` getGcodeFileText(fileName, gcodeText) `Get the gcode text from a file if it the gcode text is empty and if the file is a gcode file.` getGcodeWithoutDuplication(duplicateWord, gcodeText) `Get gcode text without duplicate first words.` 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` getLineWithValueString(character, line, splitLine, valueString) `Get the line with a valueString.` getLocationFromSplitLine(oldLocation, splitLine) `Get the location from the split line.` getRotationBySplitLine(splitLine) `Get the complex rotation from the split gcode line.` getSplitLineBeforeBracketSemicolon(line) `Get the split line before a bracket or semicolon.` getStringFromCharacterSplitLine(character, splitLine) `Get the string after the first occurence of the character in the split line.` getTagBracketedLine(tagName, value) `Get line with a begin tag, value and end tag.` getTagBracketedProcedure(procedure) `Get line with a begin procedure tag, procedure and end procedure tag.` isProcedureDone(gcodeText, procedure) `Determine if the procedure has been done on the gcode text.` isProcedureDoneOrFileIsEmpty(gcodeText, procedure) `Determine if the procedure has been done on the gcode text or the file is empty.` isThereAFirstWord(firstWord, lines, startIndex) `Parse gcode until the first word if there is one.`

Data
`` |  | __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' absolute_import = _Feature((2, 5, 0, 'alpha', 1), (2, 7, 0, 'alpha', 0), 16384)

Author
`` |  | Enrique Perez (perez_enrique@yahoo.com)