thinking about G-code backplot, I note that an alternative to 'roll your own parser' + XML is to use the existing rs274ngc interpreter as it comes with emc2
it is a fairly underdocumented corner of emc2, but it's used in Axis and all there ready to use from Python. What the interpreter does is to map G-code into calls to 'canonical
functions' which are basis for controlling the machine as well as
generating the backplot. By using the gcode module from Python it's possible to parse a G-code
file, and have the resulting 'canonical commands' be executed as calls
into Python methods.
I reverse-engineered an example, see
http://git.mah.priv.at/gitweb/rs274-python.git/tree/master:/src This parses a g-code file and reports a few calls through the canonical interface. It should be straightforward to adapt this to generate a file to stuff into the CAD package, or to directly feed a geometry into it.
You need to have emc2/lib/python on the PYTHONPATH if you use emc2 run-in-place.
See the emc2/src/emc/rs274ngc/gcodemodule.cc for details, this maps the canonical format to Python method calls. It is scantily documented but fully functional.
to get an idea about the canonical format, see emc2/src/emc/canterp/canterp.cc .
-m