21

Does anyone know of source code, ideally in C# or similar, for reading .DXF files (as used by AutoCAD etc)? If not code, then tables showing the various codes (elements / blocks / etc) and their meanings?

I am writing a reader myself, and have dead tree documentation detailing the format, but am trying to avoid writing e.g. a converter from each of the 255 ACI colours to RGB... Thanks!

Joel in Gö
  • 7,460
  • 9
  • 47
  • 77

7 Answers7

7

Cadlib from WoutWare have I been using for a couple of projects with good results.

Wout
  • 624
  • 5
  • 14
sBENdk
  • 92
  • 1
7

I have work a couple of years at developing my own DXf-Viewer in java (you could drop your own DXF file or an URL on the viewer) for 2D drawings.
The published information from AutoCAD is a good base but doesn't explain how it works.
Becoming member of the Open Design Alliance, will give you the possibility to convert several CAD formats to DXF. It may be a good idea if you are developing a commercial product.
There is a german book (http://www.crlf.de/Verlag/DXF-intern/DXF-intern.html) about DXF which really explain this format. It's expensive, but could save days of search.
The colors in the DXF Format are indexed, you must have a converter from ACI to RGB. Be careful with values 0 and 1 which having a special meaning.

Regards.

elou
  • 1,242
  • 15
  • 21
5

Update in case someone is still looking...
It's the same library, just including both links.

https://github.com/haplokuon/netDxf
https://www.nuget.org/packages/netDXF/

Ian
  • 679
  • 6
  • 10
  • 1
    netDxf is good if you are ok with a net framework 4.5 depedency. If you need netcore/netstandard support, I've had good results with https://github.com/ixmilia/dxf – Sam Sippe Jul 05 '19 at 05:11
4

Fortunately AutoCAD publish the DXF format information here: DXF Formats

Fusseldieb
  • 1,324
  • 2
  • 19
  • 44
Lazarus
  • 41,906
  • 4
  • 43
  • 54
2

You may want to try the Open Design Alliance. It's a while since I looked at it myself, but they had a load of C libraries for dealing with various AutoCAD files.

robertc
  • 74,533
  • 18
  • 193
  • 177
  • The prices are, however, seriously steep, especially if you intend to actually write software which also the library and then sell it. – Joel in Gö Feb 11 '11 at 16:53
2

Here is a link to a CodeProject dxf reader; it seems very limited (and not particularly well done) though.

Joel in Gö
  • 7,460
  • 9
  • 47
  • 77
0

Here is another open source dxf reader, in Java. Buggy however!

Joel in Gö
  • 7,460
  • 9
  • 47
  • 77