Net 程序库,用 c # 编程读写 AutoCAD dxf 文件。包含使用指南。 它支持文本和二进制格式的 AutoCad2000、 AutoCad2004、 AutoCad2007、 AutoCad2010、 AutoCad2013和 AutoCad2018 dxf 数据库版本。代码示例:
public static void Main()
{
// your dxf file name
string file = "sample.dxf";
// by default it will create an AutoCad2000 DXF version
DxfDocument dxf = new DxfDocument();
// an entity
Line entity = new Line(new Vector2(5, 5), new Vector2(10, 5));
// add your entities here
dxf.AddEntity(entity);
// save to file
dxf.Save(file);
// this check is optional but recommended before loading a DXF file
DxfVersion dxfVersion = DxfDocument.CheckDxfFileVersion(file);
// netDxf is only compatible with AutoCad2000 and higher DXF version
if (dxfVersion < DxfVersion.AutoCad2000) return;
// load file
DxfDocument loaded = DxfDocument.Load(file);
}
1