On Sat, Apr 09, 2005 at 06:40:15AM -0500, aaron@...749... wrote:
Jon A. Cruz wrote:
One thing I was thinking, when I saw the first messages on this
thread,
was that even if there are some other DXF converters we might want to
do
our own anyway, since there might be higher-level semantics we could preserve differently, or might map into Inkscape-specific extensions. Thinking of some of the things wanted like diagramming, connectors,
etc.
Two links that I saw a while back that might be of interest: http://www.ribbonsoft.com/dxflib.html
Mmm, good find. That's exactly the type of thing needed.
I downloaded the code and browsed through it. It looks like to create a dxf2svg converter one would need to do this:
Create a sub-class of DL_CreationInterface called something like SvgCreator.
SvgCreator's job would be to build up a tree of SVG elements from the DXF data as parsed by this library. To do this, in SvgCreator implement all of the virtual methods in DL_CreationInterface - addCircle(), addLine(), addKnot(), etc.
Each of these routines would need to create the corresponding SVG element. I.e., in addCircle(DL_CircleData), you'd convert the contents of the DL_CircleData structure into SVG data and add it to your SVG tree.
The next question is, how do you build the SVG tree? This is basically just a data structure to contain XML data, so you could probably use some existing XML library to do it. There is also some SVG-specific code out there you could look at reusing, such as Cairo, librsvg, or even Inkscape itself, in the src/xml directory. (Anyone have a suggestion for which lib would be best to use?)
Finally, given the built-up tree, you need code to write it out to an SVG file. Presumably, whatever code you've selected for building the XML tree will include some sort of writer function, so in theory you can just call that, and you're done. :-)
So to recap, this looks pretty straightforward. To code it you'll need to be moderately comfortable with C++. You'll need to create one class, and hook two libraries together. You'll need to create a makefile for it, and set up the usual packaging stuff too, but this is all pretty straightforward. I think this'd be a 2-weekend project for someone with good C++ skills, and perhaps thrice that (but an excellent learning project) for a C++ newbie.
Anyway, wish I had time to do more than just give advice, but I hope this helps. This looks totally do-able, it just needs a bit of coding time. It'd sure be handy, and I bet it'd get used pretty widely.
Bryce