C# .NET Library for AutoCAD DXF Files Reading & Writing
Open Source .NET CAD library that enables programmers to read and write AutoCAD DXF Files. It supports 3dFace, Arc, circle, image, line, mesh & so on.
What is netDxf Library?
netDxf presents an open-source AutoCAD DXF C# .NET Library, allowing developers to access, read, and modify AutoCAD DXF Files within their custom .NET applications. The DXF™ file format serves as a structured data layout of every detail found in an AutoCAD drawing file. Essentially, each piece of data in the file is preceded by a numerical tag known as a group code. This library is designed with simplicity in mind, ensuring that using it is straightforward and user-friendly. You’ll be pleased to know that the library fully backs up AutoCad from 2000 up to 2018, encompassing various DXF database versions in text and binary configurations.
The library now fully supports a wide range of essential DXF entities, including 3dFace, Arc, circle, hatch, image, line, mesh, Insert, Leader, lightweight polyline, MLine, MText, Point, Polyline2D, Polyline3D, PolyfaceMesh, PolygonMesh, Shape, Ray, Solid, Text, Tolerance, Underlay, Wipeout, XLine, and more. It also caters to different dimensions like aligned, linear, radial, diametric, 3 point angular, 2 line angular, and ordinate. Just keep in mind that you can group all the elements, and all your DXF items might have extra data. The tool also helps you bring in AutoCad Table elements. It’s equipped to handle both basic and intricate line styles.
Getting Started with netDxf
The easiest way to install netDxf is by using Pip. Please use the following command for a smooth installation.
Install netDxf via Pip
pip install cadquery
You can also install it manually; download the latest release files directly from GitHub repository.
Create AutoCAD DXF Files via .NET Library
The open source library Docxlib has included various functionalities for adding and managing text inside word DOCX documents using Go API. . The Docxlib library has included support for adding one or more paragraphs to the word documents inside Go applications. The library provides features for setting fonts, font colors, size, and alignment, etc. of your textual contents with ease.
How to Create & Read AutoCAD DXF Files via C# .NET API?
public static void Main()
{
// your DXF file name
string file = "sample.dxf";
// create a new document, by default it will create an AutoCad2000 DXF version
DxfDocument doc = new DxfDocument();
// an entity
Line entity = new Line(new Vector2(5, 5), new Vector2(10, 5));
// add your entities here
doc.Entities.Add(entity);
// save to file
doc.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 versions
if (dxfVersion < DxfVersion.AutoCad2000) return;
// load file
DxfDocument loaded = DxfDocument.Load(file);
}
Load & Read AutoCAD DXF File via C# .NET
The open source netDxf library gives computer programmers the capability to open and read .DXF files inside their .NET application with ease. You need to provide the address of an existing file and the library will check the version of the file before loading it. Please remember that netDxf is only compatible with AutoCad2000 and higher DXF versions. Please note that the library will never be able to read some entities like REGIONs, SURFACEs, and 3DSOLIDs, since they depend on undocumented proprietary data.