tags:

views:

139

answers:

2

Are there any libraries (preferably open-source) for parsing AutoCAD files (DWG or DXF)?

A: 

Don't think you will find anything better than DWGdirect. Look here

http://www.opendwg.org/

and specifically here:

http://www.opendesign.com/the_oda_platform/dwgdirect

Kamarey
I checked that out, and it would be fine except for the fact that my application is open-source, and it seems that the license agreement with the ODA does not allow open-source distribution of an app using their libraries.
mipadi
+1  A: 

Duplicate of (or at least related to) http://stackoverflow.com/questions/169390/open-source-cad-drawing-dwg-library-in-c/ & http://stackoverflow.com/questions/298622/net-cad-component-that-can-read-write-dxf-dwg-files/

There isn't anything available for parsing DWG for free that I would regard as reliable. The Open Design Alliance tends to be cheaper & runs on more OS's than AutoDesk's RealDWG offering. The ODA has a price-tier for startups who aren't yet shipping code - RealDWG doesn't. Both the ODA and AutoDesk offer support in forums - you have to be a member of the ODA but AutoDesk's forums are at http://discussion.autodesk.com/forums/ where you can join for free.

DXF is a text-file format (similar to XML) which you can parse with anything you like - if you know what you're looking for. You may have more luck with finding a library for that (I haven't looked into it) but that would involve conversion from DWG format. Note that there are various releases of the DXF format

You can try Autodesk's DWG Trueview (free) but it is an end-user viewer - it doesn't officially offer an API. Some people have had varying degree of success in the past automating it. I haven't tried myself & I strongly suspect the latest versions have been hardened against that.

Ultimately, if you are working for high-profile clients who are likely to insist on, or at least balk at the absence of 'official' AutoCAD libraries and the "Trusted DWG" BS that goes with it then you may need to invest in a membership of the Autodesk Developer Network.

As a long-time end user I can tell you the devs at the ODA are more responsive to bug reports than AutoCAD.

CAD bloke
Although it didn't work for my purposes, this is probably the best general-purpose answer, so I'm going to accept it.
mipadi