Problem with spaces in GCode.

Help for setting up and using
Post Reply
fnord23
Posts: 1
Joined: Fri Jan 23, 2015 4:54 am

Problem with spaces in GCode.

Post by fnord23 »

Recently I have been trying to use Autoleveller (0.8.6) and I have run into a small but annoying problem.

I generate most of my GCode from an Inkscape plugin called 'GCodetools'. It is a bit creaky, but it gets the job done fast and lets you work in an art environment rather than a CAD program. The GCode it generates always works with LinuxCNC, so I'm usually happy. It does however write spaces into its Arc commands.

For example:

Code: Select all

G02 X 23.9447 Y 8.0243 Z -0.5000 I 2432.7112 J -2189.4560 F 50.0000
G02 X 24.4808 Y 8.6195 Z -0.5000 I 1597.6463 J -1438.7884
G03 X 24.7076 Y 8.8702 Z -0.5000 I -30.9748 J 28.2395
Autoleveller refuses to process this file with an error that says: "[ERROR] Surface - Arc moves must include an I or J or R"

If I manually remove the spaces from the Arc commands like this:

Code: Select all

G02 X23.9447 Y8.0243 Z-0.5000 I2432.7112 J-2189.4560 F50.0000
Autoleveller will happily process up to point where I stopped editing, then throw the error.

I work with natural materials a lot (mostly wood) that have a curve to them, so I am quite excited by Autoleveller and how easy it seems to be to use. In the meantime I'll modify GCodetools to stop using spaces.
daedelus
Site Admin
Posts: 387
Joined: Tue Oct 01, 2013 1:41 pm
Location: London, UK
Contact:

Re: Problem with spaces in GCode.

Post by daedelus »

Thanks for this,

I had an email recently from someone using a program called 'SL2M3' which produced spaces between axis letters and the number value and yes Autoleveller refused to read this too.

This has always been a problem for me, i.e. to write Autoleveller to recognize all the different styles of gcode produced by all the different 'CAM' programs. However, I think the majority of programs dont apply spaces here and Autoleveller was programmed to read it like this which is why Autoleveller struggles to read gcode which does have spaces.

The best solution would be to ask your program not to produce spaces at all if possible but another fix (quick and dirty) might be to use a regular expression in your text editor to remove spaces.

So, with your gcode open in your text editor (I recommend notepad++) use find and replace:

Find: ^(.*)\s(.*)$
Replace: \1\2
notepad++ remove spaces
notepad++ remove spaces
removeSpaces.png (30.05 KiB) Viewed 3380 times
Make sure the regular expressions radio button is checked

Clicking 'replace all' removes the final space on each line, so keep clicking 'replace all' until it says "Replace All: 0 occurence was replaced"
http://www.autoleveller.co.uk/. Software to probe and adjust a GCode file for PCB's or any probe-able surface.

http://www.autoleveller.co.uk/cnc-probe-guide/. A short guide to setting up the probe.

-James
Post Reply