1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module skeinforge_tools.skeinforge_utilities.gcodec</title>
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="skeinforge_tools.html"><font color="#ffffff">skeinforge_tools</font></a>.<a href="skeinforge_tools.skeinforge_utilities.html"><font color="#ffffff">skeinforge_utilities</font></a>.gcodec</strong></big></big> ($Date: 2008/21/04 $)</font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/enrique/Desktop/backup/babbleold/script/reprap/pyRepRap/skeinforge_tools/skeinforge_utilities/gcodec.py">/home/enrique/Desktop/backup/babbleold/script/reprap/pyRepRap/skeinforge_tools/skeinforge_utilities/gcodec.py</a></font></td></tr></table>
<p><tt>Gcodec is a collection of utilities to decode and encode gcode.<br>
<br>
To run gcodec, install python 2.x on your machine, which is avaliable from <a href="http://www.python.org/download/">http://www.python.org/download/</a><br>
<br>
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.<br>
<br>
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.<br>
<br>
>>> from gcodec import *<br>
>>> <a href="#-getFileText">getFileText</a>('Screw Holder Bottom_export.gcode')<br>
'G90<br>
G21<br>
M103<br>
M105<br>
M106<br>
M110 S60.0<br>
M111 S30.0<br>
M108 S210.0<br>
M104 S235.0<br>
G1 X0.37 Y-4.07 Z1.9 F60.0<br>
M101<br>
<br>
..<br>
many lines of text<br>
..</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="__init__.html">__init__</a><br>
<a href="cStringIO.html">cStringIO</a><br>
</td><td width="25%" valign=top><a href="skeinforge_tools.skeinforge_utilities.euclidean.html">skeinforge_tools.skeinforge_utilities.euclidean</a><br>
<a href="os.html">os</a><br>
</td><td width="25%" valign=top><a href="sys.html">sys</a><br>
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="skeinforge_tools.skeinforge_utilities.gcodec.html#BoundingRectangle">BoundingRectangle</a>
</font></dt><dt><font face="helvetica, arial"><a href="skeinforge_tools.skeinforge_utilities.gcodec.html#DistanceFeedRate">DistanceFeedRate</a>
</font></dt></dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="BoundingRectangle">class <strong>BoundingRectangle</strong></a></font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>A class to get the corners of a gcode text.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="BoundingRectangle-getFromGcodeLines"><strong>getFromGcodeLines</strong></a>(self, lines, radius)</dt><dd><tt>Parse gcode text and get the minimum and maximum corners.</tt></dd></dl>
<dl><dt><a name="BoundingRectangle-isPointInside"><strong>isPointInside</strong></a>(self, point)</dt><dd><tt>Determine if the point is inside the bounding rectangle.</tt></dd></dl>
<dl><dt><a name="BoundingRectangle-parseCorner"><strong>parseCorner</strong></a>(self, line)</dt><dd><tt>Parse a gcode line and use the location to update the bounding corners.</tt></dd></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="DistanceFeedRate">class <strong>DistanceFeedRate</strong></a></font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>A class to limit the z feed rate and round values.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="DistanceFeedRate-__init__"><strong>__init__</strong></a>(self)</dt></dl>
<dl><dt><a name="DistanceFeedRate-addGcodeFromFeedRateThreadZ"><strong>addGcodeFromFeedRateThreadZ</strong></a>(self, feedRateMinute, thread, z)</dt><dd><tt>Add a thread to the output.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-addGcodeFromLoop"><strong>addGcodeFromLoop</strong></a>(self, loop, z)</dt><dd><tt>Add the gcode loop.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-addGcodeFromThreadZ"><strong>addGcodeFromThreadZ</strong></a>(self, thread, z)</dt><dd><tt>Add a thread to the output.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-addGcodeMovementZ"><strong>addGcodeMovementZ</strong></a>(self, point, z)</dt><dd><tt>Add a movement to the output.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-addGcodeMovementZWithFeedRate"><strong>addGcodeMovementZWithFeedRate</strong></a>(self, feedRateMinute, point, z)</dt><dd><tt>Add a movement to the output.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-addLine"><strong>addLine</strong></a>(self, line)</dt><dd><tt>Add a line of text and a newline to the output.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-addLines"><strong>addLines</strong></a>(self, lines)</dt><dd><tt>Add lines of text to the output.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-addLinesSetAbsoluteDistanceMode"><strong>addLinesSetAbsoluteDistanceMode</strong></a>(self, lines)</dt><dd><tt>Add lines of text to the output.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-addPerimeterBlock"><strong>addPerimeterBlock</strong></a>(self, loop, z)</dt><dd><tt>Add the perimeter gcode block for the loop.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-addTagBracketedLine"><strong>addTagBracketedLine</strong></a>(self, tagName, value)</dt><dd><tt>Add a begin tag, balue and end tag.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-getBoundaryLine"><strong>getBoundaryLine</strong></a>(self, location)</dt><dd><tt>Get boundary gcode line.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-getFirstWordMovement"><strong>getFirstWordMovement</strong></a>(self, firstWord, location)</dt><dd><tt>Get the start of the arc line.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-getLineWithFeedRate"><strong>getLineWithFeedRate</strong></a>(self, feedRateMinute, line, splitLine)</dt><dd><tt>Get the line with a feed rate.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-getLineWithX"><strong>getLineWithX</strong></a>(self, line, splitLine, x)</dt><dd><tt>Get the line with an x.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-getLineWithY"><strong>getLineWithY</strong></a>(self, line, splitLine, y)</dt><dd><tt>Get the line with a y.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-getLineWithZ"><strong>getLineWithZ</strong></a>(self, line, splitLine, z)</dt><dd><tt>Get the line with a z.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-getLineWithZLimitedFeedRate"><strong>getLineWithZLimitedFeedRate</strong></a>(self, feedRateMinute, line, location, splitLine)</dt><dd><tt>Get a replaced limited gcode movement line.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-getLinearGcodeMovement"><strong>getLinearGcodeMovement</strong></a>(self, point, z)</dt><dd><tt>Get a linear gcode movement.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-getLinearGcodeMovementWithFeedRate"><strong>getLinearGcodeMovementWithFeedRate</strong></a>(self, feedRateMinute, point, z)</dt><dd><tt>Get a z limited gcode movement.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-getLinearGcodeMovementWithZLimitedFeedRate"><strong>getLinearGcodeMovementWithZLimitedFeedRate</strong></a>(self, feedRateMinute, location)</dt><dd><tt>Get a z limited gcode movement.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-getRounded"><strong>getRounded</strong></a>(self, number)</dt><dd><tt>Get number rounded to the number of carried decimal places as a string.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-getTagBracketedLine"><strong>getTagBracketedLine</strong></a>(self, tagName, value)</dt><dd><tt>Add a begin tag, balue and end tag.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-getZLimitedFeedRate"><strong>getZLimitedFeedRate</strong></a>(self, deltaZ, distance, feedRateMinute)</dt><dd><tt>Get the z limited feed rate.</tt></dd></dl>
<dl><dt><a name="DistanceFeedRate-parseSplitLine"><strong>parseSplitLine</strong></a>(self, firstWord, splitLine)</dt><dd><tt>Parse gcode split line and store the parameters.</tt></dd></dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-addLineAndNewlineIfNecessary"><strong>addLineAndNewlineIfNecessary</strong></a>(line, output)</dt><dd><tt>Add the line and if the line does not end with a newline add a newline.</tt></dd></dl>
<dl><dt><a name="-createInitFile"><strong>createInitFile</strong></a>()</dt><dd><tt>Create the __init__.py file.</tt></dd></dl>
<dl><dt><a name="-findWords"><strong>findWords</strong></a>(fileNames, search)</dt><dd><tt>Find in files the search.</tt></dd></dl>
<dl><dt><a name="-getAbsoluteFolderPath"><strong>getAbsoluteFolderPath</strong></a>(filePath, folderName<font color="#909090">=''</font>)</dt><dd><tt>Get the double value of the word after the first letter.</tt></dd></dl>
<dl><dt><a name="-getDoubleAfterFirstLetter"><strong>getDoubleAfterFirstLetter</strong></a>(word)</dt><dd><tt>Get the double value of the word after the first letter.</tt></dd></dl>
<dl><dt><a name="-getDoubleForLetter"><strong>getDoubleForLetter</strong></a>(letter, splitLine)</dt><dd><tt>Get the double value of the word after the first occurence of the letter in the split line.</tt></dd></dl>
<dl><dt><a name="-getDoubleFromCharacterSplitLine"><strong>getDoubleFromCharacterSplitLine</strong></a>(character, splitLine)</dt><dd><tt>Get the double value of the string after the first occurence of the character in the split line.</tt></dd></dl>
<dl><dt><a name="-getDoubleFromCharacterSplitLineValue"><strong>getDoubleFromCharacterSplitLineValue</strong></a>(character, splitLine, value)</dt><dd><tt>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.</tt></dd></dl>
<dl><dt><a name="-getFeedRateMinute"><strong>getFeedRateMinute</strong></a>(feedRateMinute, splitLine)</dt><dd><tt>Get the feed rate per minute if the split line has a feed rate.</tt></dd></dl>
<dl><dt><a name="-getFilePathWithUnderscoredBasename"><strong>getFilePathWithUnderscoredBasename</strong></a>(fileName, suffix)</dt><dd><tt>Get the file path with all spaces in the basename replaced with underscores.</tt></dd></dl>
<dl><dt><a name="-getFileText"><strong>getFileText</strong></a>(fileName, readMode<font color="#909090">='r'</font>, printWarning<font color="#909090">=True</font>)</dt><dd><tt>Get the entire text of a file.</tt></dd></dl>
<dl><dt><a name="-getFileTextInFileDirectory"><strong>getFileTextInFileDirectory</strong></a>(fileInDirectory, fileName, readMode<font color="#909090">='r'</font>)</dt><dd><tt>Get the entire text of a file in the directory of the file in directory.</tt></dd></dl>
<dl><dt><a name="-getFilesWithFileTypeWithoutWords"><strong>getFilesWithFileTypeWithoutWords</strong></a>(fileType, words<font color="#909090">=[]</font>, fileInDirectory<font color="#909090">=''</font>)</dt><dd><tt>Get files which have a given file type, but with do not contain a word in a list.</tt></dd></dl>
<dl><dt><a name="-getFilesWithFileTypesWithoutWords"><strong>getFilesWithFileTypesWithoutWords</strong></a>(fileTypes, words<font color="#909090">=[]</font>, fileInDirectory<font color="#909090">=''</font>)</dt><dd><tt>Get files which have a given file type, but with do not contain a word in a list.</tt></dd></dl>
<dl><dt><a name="-getFirstWord"><strong>getFirstWord</strong></a>(splitLine)</dt><dd><tt>Get the first word of a split line.</tt></dd></dl>
<dl><dt><a name="-getFirstWordFromLine"><strong>getFirstWordFromLine</strong></a>(line)</dt><dd><tt>Get the first word of a line.</tt></dd></dl>
<dl><dt><a name="-getGcodeFileText"><strong>getGcodeFileText</strong></a>(fileName, gcodeText)</dt><dd><tt>Get the gcode text from a file if it the gcode text is empty and if the file is a gcode file.</tt></dd></dl>
<dl><dt><a name="-getHasPrefix"><strong>getHasPrefix</strong></a>(name, prefix)</dt><dd><tt>Determine if the word begins with the prefix.</tt></dd></dl>
<dl><dt><a name="-getHasSuffix"><strong>getHasSuffix</strong></a>(name, suffix)</dt><dd><tt>Determine if the word ends with the suffix.</tt></dd></dl>
<dl><dt><a name="-getLocationFromSplitLine"><strong>getLocationFromSplitLine</strong></a>(oldLocation, splitLine)</dt><dd><tt>Get the location from the split line.</tt></dd></dl>
<dl><dt><a name="-getModuleWithDirectoryPath"><strong>getModuleWithDirectoryPath</strong></a>(directoryPath, fileName)</dt><dd><tt>Get the module from the fileName and folder name.</tt></dd></dl>
<dl><dt><a name="-getModuleWithPath"><strong>getModuleWithPath</strong></a>(path)</dt><dd><tt>Get the module from the path.</tt></dd></dl>
<dl><dt><a name="-getPluginFileNamesFromDirectoryPath"><strong>getPluginFileNamesFromDirectoryPath</strong></a>(directoryPath)</dt><dd><tt>Get the file names of the python plugins in the directory path.</tt></dd></dl>
<dl><dt><a name="-getPythonDirectoryNames"><strong>getPythonDirectoryNames</strong></a>(directoryName)</dt><dd><tt>Get the python directories.</tt></dd></dl>
<dl><dt><a name="-getPythonDirectoryNamesRecursively"><strong>getPythonDirectoryNamesRecursively</strong></a>(directoryName<font color="#909090">=''</font>)</dt><dd><tt>Get the python directories recursively.</tt></dd></dl>
<dl><dt><a name="-getPythonFileNamesExceptInit"><strong>getPythonFileNamesExceptInit</strong></a>(fileInDirectory<font color="#909090">=''</font>)</dt><dd><tt>Get the python fileNames of the directory which the fileInDirectory is in, except for the __init__.py file.</tt></dd></dl>
<dl><dt><a name="-getPythonFileNamesExceptInitRecursively"><strong>getPythonFileNamesExceptInitRecursively</strong></a>(directoryName<font color="#909090">=''</font>)</dt><dd><tt>Get the python fileNames of the directory recursively, except for the __init__.py files.</tt></dd></dl>
<dl><dt><a name="-getSplitLineBeforeBracketSemicolon"><strong>getSplitLineBeforeBracketSemicolon</strong></a>(line)</dt><dd><tt>Get the split line before a bracket or semicolon.</tt></dd></dl>
<dl><dt><a name="-getStringFromCharacterSplitLine"><strong>getStringFromCharacterSplitLine</strong></a>(character, splitLine)</dt><dd><tt>Get the string after the first occurence of the character in the split line.</tt></dd></dl>
<dl><dt><a name="-getSummarizedFileName"><strong>getSummarizedFileName</strong></a>(fileName)</dt><dd><tt>Get the fileName basename if the file is in the current working directory, otherwise return the original full name.</tt></dd></dl>
<dl><dt><a name="-getTextIfEmpty"><strong>getTextIfEmpty</strong></a>(fileName, text)</dt><dd><tt>Get the text from a file if it the text is empty.</tt></dd></dl>
<dl><dt><a name="-getTextLines"><strong>getTextLines</strong></a>(text)</dt><dd><tt>Get the all the lines of text of a text.</tt></dd></dl>
<dl><dt><a name="-getUnmodifiedGCodeFiles"><strong>getUnmodifiedGCodeFiles</strong></a>(fileInDirectory<font color="#909090">=''</font>)</dt><dd><tt>Get gcode files which are not modified.</tt></dd></dl>
<dl><dt><a name="-getUntilDot"><strong>getUntilDot</strong></a>(text)</dt><dd><tt>Get the text until the last dot, if any.</tt></dd></dl>
<dl><dt><a name="-getVersionFileName"><strong>getVersionFileName</strong></a>()</dt><dd><tt>Get the file name of the version date.</tt></dd></dl>
<dl><dt><a name="-getWithoutBracketsEqualTab"><strong>getWithoutBracketsEqualTab</strong></a>(line)</dt><dd><tt>Get a string without the greater than sign, the bracket and less than sign, the equal sign or the tab.</tt></dd></dl>
<dl><dt><a name="-indexOfStartingWithSecond"><strong>indexOfStartingWithSecond</strong></a>(letter, splitLine)</dt><dd><tt>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</tt></dd></dl>
<dl><dt><a name="-isFileWithFileTypeWithoutWords"><strong>isFileWithFileTypeWithoutWords</strong></a>(fileType, fileName, words)</dt><dd><tt>Determine if file has a given file type, but with does not contain a word in a list.</tt></dd></dl>
<dl><dt><a name="-isProcedureDone"><strong>isProcedureDone</strong></a>(gcodeText, procedure)</dt><dd><tt>Determine if the procedure has been done on the gcode text.</tt></dd></dl>
<dl><dt><a name="-isProcedureDoneOrFileIsEmpty"><strong>isProcedureDoneOrFileIsEmpty</strong></a>(gcodeText, procedure)</dt><dd><tt>Determine if the procedure has been done on the gcode text or the file is empty.</tt></dd></dl>
<dl><dt><a name="-isThereAFirstWord"><strong>isThereAFirstWord</strong></a>(firstWord, lines, startIndex)</dt><dd><tt>Parse gcode until the first word if there is one.</tt></dd></dl>
<dl><dt><a name="-replaceWords"><strong>replaceWords</strong></a>(fileNames, original, replacement)</dt><dd><tt>Replace in files the original with the replacement.</tt></dd></dl>
<dl><dt><a name="-writeFileMessageEnd"><strong>writeFileMessageEnd</strong></a>(end, fileName, fileText, message)</dt><dd><tt>Write to a fileName with a suffix and print a message.</tt></dd></dl>
<dl><dt><a name="-writeFileText"><strong>writeFileText</strong></a>(fileName, fileText, writeMode<font color="#909090">='w+'</font>)</dt><dd><tt>Write a text to a file.</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>__author__</strong> = 'Enrique Perez (perez_enrique@yahoo.com)'<br>
<strong>__date__</strong> = '$Date: 2008/21/04 $'<br>
<strong>__license__</strong> = 'GPL 3.0'<br>
<strong>absolute_import</strong> = _Feature((2, 5, 0, 'alpha', 1), (2, 7, 0, 'alpha', 0), 16384)</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#7799ee">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr>
<tr><td bgcolor="#7799ee"><tt> </tt></td><td> </td>
<td width="100%">Enrique Perez (perez_enrique@yahoo.com)</td></tr></table>
</body></html>
|