@@ -34,151 +34,151 @@ def run_from_line_get(file, startLine):
3434 for line in inFile :
3535 # code before selected line
3636 if count < startLine :
37- preData .append (line . lower () )
37+ preData .append (line )
3838 # remaining code
3939 else :
4040 if count == startLine :
41- if 'g21 ' in line :
42- newData .append ('g21 ' )
43- elif 'g20 ' in line :
44- newData .append ('g20 ' )
45- if line .strip ().startswith ('m66p3 ' ):
41+ if 'G21 ' in line :
42+ newData .append ('G21 ' )
43+ elif 'G20 ' in line :
44+ newData .append ('G20 ' )
45+ if line .strip ().startswith ('M66P3 ' ):
4646 material .append (line .strip ())
4747 # find the type of first move
48- if not codes ['move' ]['isSet' ] and not 'g53g0 ' in line and not 'g20 ' in line and not 'g21' in line :
49- if 'g00 ' in line :
48+ if not codes ['move' ]['isSet' ] and not 'G53G0 ' in line and not 'G20 ' in line and not 'g21' in line :
49+ if 'G00 ' in line :
5050 codes ['move' ]['isSet' ] = True
5151 codes ['move' ]['isG00' ] = True
52- codes ['x2' ] = get_rfl_pos (line .strip (), codes ['x2' ], 'x ' )
53- codes ['y2' ] = get_rfl_pos (line .strip (), codes ['y2' ], 'y ' )
54- if 'g01 ' in line or 'g02 ' in line or 'g03 ' in line :
52+ codes ['x2' ] = get_rfl_pos (line .strip (), codes ['x2' ], 'X ' )
53+ codes ['y2' ] = get_rfl_pos (line .strip (), codes ['y2' ], 'Y ' )
54+ if 'G01 ' in line or 'G02 ' in line or 'G03 ' in line :
5555 codes ['move' ]['isSet' ] = True
5656 codes ['move' ]['isG00' ] = False
57- codes ['x2' ] = get_rfl_pos (line .strip (), codes ['x2' ], 'x ' )
58- codes ['y2' ] = get_rfl_pos (line .strip (), codes ['y2' ], 'y ' )
59- if 'm03' in line :# print('SPINDLE FOUND')
57+ codes ['x2' ] = get_rfl_pos (line .strip (), codes ['x2' ], 'X ' )
58+ codes ['y2' ] = get_rfl_pos (line .strip (), codes ['y2' ], 'Y ' )
59+ if 'm03' in line :
6060 if not codes ['spindle' ]['line' ]:
61- codes ['spindle' ]['line' ] = line .lower (). strip ()
61+ codes ['spindle' ]['line' ] = line .strip ()
6262 continue
6363 codes ['spindle' ]['line' ] = line .strip ()
64- postData .append (line . lower () )
64+ postData .append (line )
6565 count += 1
6666 # read all lines before selected line to get last used codes
6767 for line in preData :
6868 if line .startswith ('(' ):
6969 if line .startswith ('(o=' ):
7070 material = [line .strip ()]
7171 continue
72- elif line .startswith ('m190 ' ):
72+ elif line .startswith ('M190 ' ):
7373 material .append (line .strip ())
7474 continue
75- elif line .replace (' ' ,'' ).startswith ('m66p3 ' ):
75+ elif line .replace (' ' ,'' ).startswith ('M66P3 ' ):
7676 material .append (line .strip ())
7777 continue
7878 elif line .startswith ('#' ):
7979 params .append (line .strip ())
8080 continue
81- for t1 in ['g20 ' ,'g21 ' ,'g40 ' ,'g41 .1' ,'g42 .1' ,'g61 ' ,'g61 .1' ,'g64 ' ,'g90 ' ,'g90 .1' ,'g91 ' ,'g91 .1' ]:
81+ for t1 in ['G20 ' ,'G21 ' ,'G40 ' ,'G41 .1' ,'G42 .1' ,'G61 ' ,'G61 .1' ,'G64 ' ,'G90 ' ,'G90 .1' ,'G91 ' ,'G91 .1' ]:
8282 if t1 in line :
8383 if t1 [1 ] == '2' :
8484 codes ['g2_' ] = t1
8585 elif t1 [1 ] == '4' :
8686 codes ['g4_' ] = t1
87- if t1 != 'g40 ' :
87+ if t1 != 'G40 ' :
8888 cutComp = True
8989 else :
9090 cutComp = False
9191 elif t1 [1 ] == '6' :
9292 codes ['g6_' ] = t1
93- if t1 == 'g64 ' :
93+ if t1 == 'G64 ' :
9494 tmp = line .split ('64' )[1 ]
95- if tmp [0 ] == 'p ' :
95+ if tmp [0 ] == 'P ' :
9696 p = ''
9797 tmp = tmp [1 :]
9898 while 1 :
99- if tmp [0 ] in '.0123456789q ' :
99+ if tmp [0 ] in '.0123456789Q ' :
100100 p += tmp [0 ]
101101 tmp = tmp [1 :]
102102 else :
103103 break
104- codes ['g6_' ] = 'g64p {}' .format (p )
105- elif t1 == 'g90 ' and not 'g90 .1' in line :
106- codes ['g9_' ] = 'g90 '
107- elif t1 == 'g91 ' and not 'g91 .1' in line :
108- codes ['g9_' ] = 'g91 '
109- elif t1 == 'g90 .1' in line :
110- codes ['g9arc' ] = 'g90 .1'
111- elif t1 == 'g91 .1' in line :
112- codes ['g9arc' ] = 'g91 .1'
113- if 'g00 ' in line and not 'g53g00 ' in line :
114- codes ['last' ]['code' ] = 'g0 '
115- if 'g01 ' in line :
116- tmp = line .split ('g01 ' )[1 ]
104+ codes ['g6_' ] = 'G64P {}' .format (p )
105+ elif t1 == 'G90 ' and not 'G90 .1' in line :
106+ codes ['g9_' ] = 'G90 '
107+ elif t1 == 'G91 ' and not 'G91 .1' in line :
108+ codes ['g9_' ] = 'G91 '
109+ elif t1 == 'G90 .1' in line :
110+ codes ['g9arc' ] = 'G90 .1'
111+ elif t1 == 'G91 .1' in line :
112+ codes ['g9arc' ] = 'G91 .1'
113+ if 'G00 ' in line and not 'G53g00 ' in line :
114+ codes ['last' ]['code' ] = 'G0 '
115+ if 'G01 ' in line :
116+ tmp = line .split ('G01 ' )[1 ]
117117 if tmp [0 ] not in '0123456789' :
118- codes ['last' ]['code' ] = 'g01 '
119- if 'g02 ' in line :
120- tmp = line .split ('g02 ' )[1 ]
118+ codes ['last' ]['code' ] = 'G01 '
119+ if 'G02 ' in line :
120+ tmp = line .split ('G02 ' )[1 ]
121121 if tmp [0 ] not in '0123456789' :
122- codes ['last' ]['code' ] = 'g02 '
123- if 'g03 ' in line :
124- tmp = line .split ('g03 ' )[1 ]
122+ codes ['last' ]['code' ] = 'G02 '
123+ if 'G03 ' in line :
124+ tmp = line .split ('G03 ' )[1 ]
125125 if tmp [0 ] not in '0123456789' :
126- codes ['last' ]['code' ] = 'g03 '
127- if 'x ' in line :
128- codes ['x1' ] = get_rfl_pos (line .strip (), codes ['x1' ], 'x ' )
129- if 'y ' in line :
130- codes ['y1' ] = get_rfl_pos (line .strip (), codes ['y1' ], 'y ' )
131- if 'm03 $' in line .replace (' ' ,'' ) and not codes ['spindle' ]['line' ]:
126+ codes ['last' ]['code' ] = 'G03 '
127+ if 'X ' in line :
128+ codes ['x1' ] = get_rfl_pos (line .strip (), codes ['x1' ], 'X ' )
129+ if 'Y ' in line :
130+ codes ['y1' ] = get_rfl_pos (line .strip (), codes ['y1' ], 'Y ' )
131+ if 'M03 $' in line .replace (' ' ,'' ) and not codes ['spindle' ]['line' ]:
132132 codes ['spindle' ]['line' ] = line .strip ()
133- if 'm62p3 ' in line .replace (' ' ,'' ):
134- codes ['d3' ] = 'm62p3 (Disable Torch)'
135- elif 'm63p3 ' in line .replace (' ' ,'' ):
136- codes ['d3' ] = 'm63p3 (Enable Torch)'
137- elif 'm64p3 ' in line .replace (' ' ,'' ):
138- codes ['d3' ] = 'm64p3 (Disable Torch)'
139- elif 'm65p3 ' in line .replace (' ' ,'' ):
140- codes ['d3' ] = 'm65p3 (Enable Torch)'
141- if 'm62p2 ' in line .replace (' ' ,'' ):
142- codes ['d2' ] = 'm62p2 (Disable THC)'
143- elif 'm63p2 ' in line .replace (' ' ,'' ):
144- codes ['d2' ] = 'm63p2 (Enable THC)'
145- elif 'm64p2 ' in line .replace (' ' ,'' ):
146- codes ['d2' ] = 'm64p2 (Disable THC)'
147- elif 'm65p2 ' in line .replace (' ' ,'' ):
148- codes ['d2' ] = 'm65p2 (Enable THC)'
149- if 'm67e3q ' in line .replace (' ' ,'' ):
150- codes ['a3' ] = 'm67e3q '
151- tmp = line .replace (' ' ,'' ).split ('m67e3q ' )[1 ]
133+ if 'M62P3 ' in line .replace (' ' ,'' ):
134+ codes ['d3' ] = 'M62P3 (Disable Torch)'
135+ elif 'M63P3 ' in line .replace (' ' ,'' ):
136+ codes ['d3' ] = 'M63P3 (Enable Torch)'
137+ elif 'M64P3 ' in line .replace (' ' ,'' ):
138+ codes ['d3' ] = 'M64P3 (Disable Torch)'
139+ elif 'M65P3 ' in line .replace (' ' ,'' ):
140+ codes ['d3' ] = 'M65P3 (Enable Torch)'
141+ if 'M62P2 ' in line .replace (' ' ,'' ):
142+ codes ['d2' ] = 'M62P2 (Disable THC)'
143+ elif 'M63P2 ' in line .replace (' ' ,'' ):
144+ codes ['d2' ] = 'M63P2 (Enable THC)'
145+ elif 'M64P2 ' in line .replace (' ' ,'' ):
146+ codes ['d2' ] = 'M64P2 (Disable THC)'
147+ elif 'M65P2 ' in line .replace (' ' ,'' ):
148+ codes ['d2' ] = 'M65P2 (Enable THC)'
149+ if 'M67E3Q ' in line .replace (' ' ,'' ):
150+ codes ['a3' ] = 'M67E3Q '
151+ tmp = line .replace (' ' ,'' ).split ('M67E3Q ' )[1 ]
152152 while 1 :
153153 if tmp [0 ] in '-.0123456789' :
154154 codes ['a3' ] += tmp [0 ]
155155 tmp = tmp [1 :]
156156 else :
157157 break
158- pc = float (codes ['a3' ].split ('m67e3q ' )[1 ])
158+ pc = float (codes ['a3' ].split ('M67E3Q ' )[1 ])
159159 pc = pc if pc > 0 else 100
160160 codes ['a3' ] += ' (Velocity {}%)' .format (pc )
161- if 'm68e3q ' in line .replace (' ' ,'' ):
162- codes ['a3' ] = 'm68e3q '
163- tmp = line .replace (' ' ,'' ).split ('m68e3q ' )[1 ]
161+ if 'M68E3Q ' in line .replace (' ' ,'' ):
162+ codes ['a3' ] = 'M68E3Q '
163+ tmp = line .replace (' ' ,'' ).split ('M68E3Q ' )[1 ]
164164 bb = 1
165165 while 1 :
166166 if tmp [0 ] in '-.0123456789' :
167167 codes ['a3' ] += tmp [0 ]
168168 tmp = tmp [1 :]
169169 else :
170170 break
171- pc = float (codes ['a3' ].split ('m68e3q ' )[1 ])
171+ pc = float (codes ['a3' ].split ('M68E3Q ' )[1 ])
172172 pc = pc if pc > 0 else 100
173173 codes ['a3' ] += ' (Velocity {}%)' .format (pc )
174174 # test if inside a subroutine
175- if line .startswith ('o ' ):
176- if 'end ' in line :
175+ if line .startswith ('O ' ):
176+ if 'END ' in line :
177177 oSub = False
178178 else :
179179 if line [1 ] == '<' :
180- os = 'o <'
181- tmp = line .replace (' ' ,'' ).split ('o <' )[1 ]
180+ os = 'O <'
181+ tmp = line .replace (' ' ,'' ).split ('O <' )[1 ]
182182 while 1 :
183183 if tmp [0 ] != '>' :
184184 os += tmp [0 ]
@@ -187,8 +187,8 @@ def run_from_line_get(file, startLine):
187187 break
188188 oSub .append ('{}>' .format (os ))
189189 else :
190- os = 'o '
191- tmp = line .replace (' ' ,'' ).split ('o ' )[1 ]
190+ os = 'O '
191+ tmp = line .replace (' ' ,'' ).split ('O ' )[1 ]
192192 while 1 :
193193 if tmp [0 ] in '0123456789' :
194194 os += tmp [0 ]
@@ -213,17 +213,17 @@ def run_from_line_set(rflFile, data, leadin, unitsPerMm):
213213 scale = 1
214214 zMax = ''
215215 if unitsPerMm == 1 :
216- if data ['codes' ]['g2_' ] == 'g20 ' :
216+ if data ['codes' ]['g2_' ] == 'G20 ' :
217217 scale = 0.03937
218- zMax = 'g53 g00z [[#<_ini[axis_z]max_limit> - 5] * 0.03937]'
218+ zMax = 'G53 G00 Z [[#<_ini[axis_z]max_limit> - 5] * 0.03937]'
219219 else :
220- zMax = 'g53 g00z [#<_ini[axis_z]max_limit> - 5]'
220+ zMax = 'G53 G00 Z [#<_ini[axis_z]max_limit> - 5]'
221221 else :
222- if data ['codes' ]['g2_' ] == 'g21 ' :
222+ if data ['codes' ]['g2_' ] == 'G21 ' :
223223 scale = 25.4
224- zMax = 'g53 g00z [[#<_ini[axis_z]max_limit> * 25.4] - 5]'
224+ zMax = 'G53 G00 Z [[#<_ini[axis_z]max_limit> * 25.4] - 5]'
225225 else :
226- zMax = 'g53 g00z [#<_ini[axis_z]max_limit> - 0.02]'
226+ zMax = 'G53 G00 Z [#<_ini[axis_z]max_limit> - 0.02]'
227227 if data ['codes' ]['g2_' ]:
228228 data ['newData' ].append (data ['codes' ]['g2_' ])
229229 if data ['codes' ]['g4_' ]:
@@ -234,7 +234,7 @@ def run_from_line_set(rflFile, data, leadin, unitsPerMm):
234234 data ['newData' ].append (data ['codes' ]['g9_' ])
235235 if data ['codes' ]['g9arc' ]:
236236 data ['newData' ].append (data ['codes' ]['g9arc' ])
237- data ['newData' ].append ('m52 p1 ' )
237+ data ['newData' ].append ('M52 P1 ' )
238238 if data ['codes' ]['d3' ]:
239239 data ['newData' ].append (data ['codes' ]['d3' ])
240240 if data ['codes' ]['d2' ]:
@@ -259,21 +259,21 @@ def run_from_line_set(rflFile, data, leadin, unitsPerMm):
259259 # if no spindle command yet then find the next one for the correct tool
260260 if not data ['codes' ]['spindle' ]['line' ]:
261261 for line in data ['postData' ]:
262- if 'm3 $' in line .replace (' ' ,'' ):
262+ if 'M3 $' in line .replace (' ' ,'' ):
263263 data ['codes' ]['spindle' ]['line' ] = line .strip ()
264264 break
265265 # add all the code from the selected line to the end
266266 for line in data ['postData' ]:
267267 # if we have the first spindle code we don't need it again
268- if 'm03 $' in line .replace (' ' ,'' ) and data ['codes' ]['spindle' ]['code' ]:
268+ if 'M03 $' in line .replace (' ' ,'' ) and data ['codes' ]['spindle' ]['code' ]:
269269 data ['codes' ]['spindle' ]['code' ] = False
270270 continue
271- # if g00 is the first motion command after the selected line
271+ # if G00 is the first motion command after the selected line
272272 if data ['codes' ]['move' ]['isG00' ]:
273- # if g0 is the current motion command
274- if 'g00 ' in line :
275- # no need to process a g53g0 command]
276- if 'g53g00 ' in line or 'g20 ' in line or 'g21 ' in line :
273+ # if G0 is the current motion command
274+ if 'G00 ' in line :
275+ # no need to process a G53G0 command]
276+ if 'G53G00 ' in line or 'G20 ' in line or 'G21 ' in line :
277277 data ['newData' ].append (line .strip ())
278278 continue
279279 if leadin ['do' ]:
@@ -282,7 +282,7 @@ def run_from_line_set(rflFile, data, leadin, unitsPerMm):
282282 xL = data ['codes' ]['x2' ]
283283 yL = data ['codes' ]['y2' ]
284284 data ['codes' ]['spindle' ]['code' ] = set_spindle_start (xL , yL , data ['codes' ]['x2' ], data ['codes' ]['y2' ], data ['codes' ]['spindle' ]['line' ], data ['newData' ], True )
285- # no need to process any more g00 commands
285+ # no need to process any more G00 commands
286286 data ['codes' ]['move' ]['isG00' ] = False
287287 continue
288288 data ['newData' ].append (line .strip ())
@@ -309,20 +309,20 @@ def set_leadin_coordinates(x, y, scale, length, angle):
309309def set_spindle_start (xL , yL , x , y , line , newData , reply ):
310310 leadIn = {}
311311 if xL != x and yL != y :
312- newData .append ('g00x{}y {}' .format (xL , yL ))
312+ newData .append ('G00 X{} Y {}' .format (xL , yL ))
313313 leadIn ['x' ] = x
314314 leadIn ['y' ] = y
315315 else :
316316 if x and y :
317- newData .append ('g00x{}y {}' .format (x , y ))
317+ newData .append ('G00 X{} Y {}' .format (x , y ))
318318 elif x :
319- newData .append ('g00x {}' .format (x ))
319+ newData .append ('G00 X {}' .format (x ))
320320 elif y :
321- newData .append ('g00y {}' .format (y ))
321+ newData .append ('G00 Y {}' .format (y ))
322322 if line :
323323 newData .append (line )
324324 if leadIn :
325- newData .append ('g01x{}y {} (leadin)' .format (leadIn ['x' ], leadIn ['y' ]))
325+ newData .append ('G01 X{} Y {} (leadin)' .format (leadIn ['x' ], leadIn ['y' ]))
326326 return reply
327327
328328def get_rfl_pos (line , axisPos , axisLetter ):
0 commit comments