Maybe a custom script . here is one chat gpt made.
example code
(v1.6-af)
(Machine)
( vendor: Autodesk)
( model: Crossfire Pro)
( description: Langmuir)
G90 G94
G17
G20
H0
(2D Profile1)
G0 X1.3744 Y1.539
G92 Z0.
G38.2 Z-5. F100.
G38.4 Z0.5 F20.
G92 Z0.
G0 Z0.04 (IHS Springback + Backlash)
G92 Z0.
G0 Z0.15 (Pierce Height)
M3
G4 P0.6
G0 Z0.06 (Cut Height)
H1
G1 X1.276 Y1.7095 F100.
G3 X1.25 Y1.7245 I-0.026 J-0.015 F100.
G3 Y0.7755 I0. J-0.4745
G3 Y1.7245 I0. J0.4745
G3 X1.224 Y1.7095 I0. J-0.03
G1 X1.1256 Y1.539
H0
M5
G0 Z1.
G0 Y2.461
G92 Z0.
G38.2 Z-5. F100.
G38.4 Z0.5 F20.
G92 Z0.
G0 Z0.04 (IHS Springback + Backlash)
G92 Z0.
G0 Z0.15 (Pierce Height)
M3
G4 P0.6
G0 Z0.06 (Cut Height)
H1
G1 X1.224 Y2.2905 F100.
G3 X1.25 Y2.2755 I0.026 J0.015
G1 X2.25
G2 X2.2755 Y2.25 I0. J-0.0255
G1 Y0.25
G2 X2.25 Y0.2245 I-0.0255 J0.
G1 X0.25
G2 X0.2245 Y0.25 I0. J0.0255
G1 Y2.25
G2 X0.25 Y2.2755 I0.0255 J0.
G1 X1.25
G3 X1.276 Y2.2905 I0. J0.03
G1 X1.3744 Y2.461
H0
M5
G0 Z1.
M30
(PS100)
Here’s the Full Script You Can Run:
Just paste this into any Python environment (like Replit, VS Code, or even Python installed locally):
python
CopyEdit
import re
import math
gcode = """
(paste your full G-code here — same one you gave earlier)
"""
move_cmds = re.findall(r'([GM]\d+[^M]*)', gcode)
cutting = False
pierce_count = 0
cut_length = 0.0
non_cut_length = 0.0
last_x = None
last_y = None
def extract_coords(line, last_x, last_y):
x = last_x
y = last_y
if 'X' in line:
x = float(re.search(r'X([-+]?[0-9]*\.?[0-9]+)', line).group(1))
if 'Y' in line:
y = float(re.search(r'Y([-+]?[0-9]*\.?[0-9]+)', line).group(1))
return x, y
def extract_ij(line):
i = j = 0.0
if 'I' in line:
i = float(re.search(r'I([-+]?[0-9]*\.?[0-9]+)', line).group(1))
if 'J' in line:
j = float(re.search(r'J([-+]?[0-9]*\.?[0-9]+)', line).group(1))
return i, j
def calculate_arc_length(x0, y0, x1, y1, i, j, cw):
cx = x0 + i
cy = y0 + j
r = math.hypot(i, j)
v0x = x0 - cx
v0y = y0 - cy
v1x = x1 - cx
v1y = y1 - cy
dot = v0x * v1x + v0y * v1y
det = v0x * v1y - v0y * v1x
angle = math.atan2(det, dot)
if cw and angle > 0:
angle -= 2 * math.pi
elif not cw and angle < 0:
angle += 2 * math.pi
return abs(r * angle)
for line in move_cmds:
line = line.strip()
if line.startswith('M3'):
cutting = True
pierce_count += 1
elif line.startswith('M5'):
cutting = False
if line.startswith(('G0', 'G1', 'G2', 'G3')):
x, y = extract_coords(line, last_x, last_y)
if last_x is not None and last_y is not None and x is not None and y is not None:
if line.startswith('G1') or line.startswith('G0'):
dx = x - last_x
dy = y - last_y
dist = math.hypot(dx, dy)
elif line.startswith(('G2', 'G3')):
i, j = extract_ij(line)
dist = calculate_arc_length(last_x, last_y, x, y, i, j, cw=line.startswith('G2'))
if cutting:
cut_length += dist
else:
non_cut_length += dist
last_x = x
last_y = y
total_length = cut_length + non_cut_length
print("Pierce Count:", pierce_count)
print("Cut Length (in):", round(cut_length, 4))
print("Non-Cutting Travel (in):", round(non_cut_length, 4))
print("Total Travel (in):", round(total_length, 4))
You’ll Get Output Like:
java
CopyEdit
Pierce Count: 2
Cut Length (in): 11.142
Non-Cutting Travel (in): 3.567
Total Travel (in): 14.709
maybe something like this will work for you.