Search the Community
Showing results for tags 'gcode'.
Found 2 results
Hi folks, Thank you so much in advance for your help! I've been using AUTOIT for manipulating gcode. So far I've just worked through the excellent help examples and although I'm sure the resulting code is clumsy it has functioned However now I'm trying to improve and advance things and I've stumbled across REGEX.. and I'm a bit stuck. What I would like to be able to do is to 'move'/'transform' the gcode in a file and re-write it to a new file. I only need to move it in one direction(X). At the heart of this I need a script to extract all the X values and then ADD or SUBTRACT an adjustment factor to transform and rewrite the code accordingly. So far using an example script and an example input - Func Test2() Local $iMove = -4 Local $sInput = '"G1 X45.036 Y6.934 F7800.000 G1 Z0.600 F7800.000 G1 F900 G1 X48.036 Y1.076 E0.58925"' Local $sOutput = StringRegExpReplace($sInput, '(?<=[X])\d+.\d+', '\0') Display($sInput, $sOutput) EndFunc ;==>Test2 This identifies the correct values i.e 45.036 and 48.036 but is there a way to dyamically adjust them before they are replaced, by for example a factor of -4 ($iMove above). So far I can't seem to do math on the '\0' value i.e '\0'+ -4 ? Many thanks for your time and expertise!
Hi All, I'm not too code savvy but I know this is a simple one! Here's my problem, I have a folder with text files containing gcode. they are appended .nc, .ngc, and .gcode randomly. I can rename them all .ngc which is my preferred file type. In these files there's lines of gcode, carrying commands for a CNC. What I need to do is remove some comments from the beginning and format the text a certain way. I'll show an example of the original file and what I need it to look like. The files can be 20 lines or 10,000 long depending on the part. Old text: ( Header 1 text ) ( Header 2 text ) G90 (set absolute distance mode) G90.1 (set absolute distance mode for arc centers) G17 (set active plane to XY) G21 (set units to mm) #<z_safe> = 0.250 #<plunge_feed> = 5 (---------------------------------------------------------) G0 X 17.2644 Y 1.6127 M03 G1 X 2.2842 Y 8.0674 F 0.01 G1 X 15.3642 Y 17.8133 G1 X 17.2644 Y 1.6127 M05 G0 X 0.0000 Y 0.0000 M05 M02 What it needs to look like: G90 G21 G0 X17.2644 Y1.6127 M03 G1 X2.2842 Y8.0674 <--- copy and paste above the next m05 G1 X15.3642 Y17.8133 G1 X17.2644 Y1.6127 G1 X2.2842 Y8.0674 <--- pasted here M05 G0 X0.000 Y0.000 M05 M02 Some things to note: g90 sets absolute coordinate mode, g21 tets units to mm, g0 is first coordinate to move the tool to. This is an important step: m03 is what turns on a laser. I need the first coordinate after every m03 to be copied to the line above m05 for each chunk of gcode. the very last m05 before the m02 needs to be ignored. There are multiple chunks with m03 x,ys then m05. each chunk is going to have different coordinates after the m03. I have no idea where to start other than find the line with the wanted string, m03. dont know how to handle m05 though... any help is very much appreciated!