A portable .NET library for reading and writing DXF and DXB files. Clone and build locally or directly consume the NuGet package.
Open a DXF file:
using System.IO;
using IxMilia.Dxf;
using IxMilia.Dxf.Entities;
// ...
DxfFile dxfFile;
using (FileStream fs = new FileStream(@"C:\Path\To\File.dxf", FileMode.Open))
{
dxfFile = DxfFile.Load(fs);
}
foreach (DxfEntity entity in dxfFile.Entities)
{
switch (entity.EntityType)
{
case DxfEntityType.Line:
DxfLine line = (DxfLine)entity;
// ...
break;
// ...
}
}
Save a DXF file:
using System.IO;
using IxMilia.Dxf;
using IxMilia.Dxf.Entities;
// ...
DxfFile dxfFile = new DxfFile();
dxfFile.Entities.Add(new DxfLine(new DxfPoint(0, 0, 0), new DxfPoint(50, 50, 0)));
// ...
using (FileStream fs = new FileStream(@"C:\Path\To\File.dxf", FileMode.Open))
{
dxfFile.Save(fs);
}
Support for DXF files is complete from versions R10 through R2014 EXCEPT for the following entities:
- HATCH
- MESH
- MLEADER
- SURFACE
- TABLE
- VIEWPORT
Since I don't want to fall afoul of Autodesk's lawyers, this repo can't include the actual DXF documentation. It can, however contain links to the official documents that I've been able to scrape together. For most scenarios the 2014 documentation should suffice, but all other versions are included here for backwards compatibility and reference between versions.
R11 (differences between R10 and R11)
R13 (self-extracting 16-bit executable)
2007 (Autodesk's link erroneously points to the R2008 documentation)
These links were compiled from the archive.org May 9, 2013 snapshot of http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=12272454&linkID=10809853 (https://web.archive.org/web/20130509144333/http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=12272454&linkID=10809853)