Parsing through files is a common thing to do. In python I'd just read 
each line of the file and remember the last line to get the XY 
coordinates to calculate the new offsets when you encounter a G2 or G3. 
I've written several G code generators you can see them on the wiki for 
inspiration. Look at the Arc Generator for my code to calculate arcs.

JT


On 5/29/2016 5:05 PM, linden wrote:
> Hello all
>       I  am trying to modify a script to convert G code programs that
> have there G2 and G3 arc centers (I and J) defined in relative terms to
> absolute values.
> ie as the program is now it will run with G90 I need it to run properly
> with G90.1 Is there a way to do this with python. Can I get it to read
> through the lines of the program until it finds an I J or K and then go
> back to the previous line and add the current I value to the X value of
> the previous line to make the new I value absolute.
>         I am sure this has been done before some where if some one has an
> example they could share or suggestions I would be much obliged. Is this
> even possible. I would prefer to do this with python and integrate it in
> to the current script (see snippet below) but I could live with bash if
> it was easer. Below are the lines in the current python script that read
> through the code and truncates the decimal places displayed. Could I add
> a block similar to this that when through before and did the conversion.
> Any suggestions or am i trying to do the imposable.
>
> Thanks Linden
>
> def parse(pathobj):
>       out = ""
>       lastcommand = None
>
>       #params = ['X','Y','Z','A','B','I','J','K','F','S'] #This list
> control the order of parameters
>       params = ['X','Y','Z','A','B','I','J','F','S','T','Q','R','L']
>
>
> for param in params:
>                   if param in c.Parameters:
>                       if param == 'F':
>                           outstring.append(param +
> format(c.Parameters['F'], '.0f'))
>                       elif param == 'S':
>                           outstring.append(param +
> format(c.Parameters[param], '.0f'))
>                       elif param == 'T':
>                           outstring.append(param + str(c.Parameters['T']))
>                       else:
>                           outstring.append(param +
> format(c.Parameters[param], '.3f'))
>
>
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
> _______________________________________________
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to