Creating gcode with 'laserengraver' extension in Inkscape sometimes makes gcode with very large values

Creating gcode with ‘laserengraver’ extension in Inkscape sometimes makes gcode with very large values of IJKR that make tgfx go crazy and chilipeppr wont display it.

Here’s a short python script to weed out those lines and produce working gcode like this: http://swigerco.com/IsingRegime_2_0001_e1.nc

short and simple version:
___________________________________

infile = open(“IsingRegime_2_0001.nc”,“r”)
lines = [line.strip(’\n’) for line in infile]
infile.close()

outfile = open("/home/chuck/IsingRegime_2_0001_e1.nc",“w”)

for line in lines:
DROPLINE=False
for token in line.split(’ ‘):
if len(token) > 1:
if (token[0] == ‘I’) | (token[0] == ‘J’) | (token[0] == ‘K’) | (token[0] == ‘R’):
val = float(token[1:len(token)])
if (val > 200) | (val < -200):
DROPLINE=True
if (DROPLINE != True):
outfile.write(line+’\n’)

outfile.close()

Interesting. It would be cool to write this as a ChiliPeppr macro. I could then publish it in the main macro list on the site so everyone has it and could just click it and hit run and be done. There are sample macros that go through the gcode and other’s that “send gcode to workspace” so you could read the gcode, modify it like you’re doing above, and then re-send the gcode to the workspace (mimicking the drag/drop of the file).