1. Products
  2.   CAD
  3.   .NET
  4.   ACadSharp
 
  

Free .NET Library for AutoCAD DXF & DWG Reading & Writing 

Open Source .NET CAD library that enables programmers to open, read, edit, write and convert AutoCAD DXF & DWG drawings with ease.

ACadSharp is a very powerful Open Source C# .NET Library that gives software developers the power to open, read and write AutoCAD DXF & DWG drawings inside their own C# applications. The library has included several important features for creating and managing DXF & DWG drawings, such as Adding a new entity to the CAD drawing, removing the unwanted entity, getting all the entities in the model, Creating a copy of a specific entity, Creating arc from Bulge, MText refactoring, create entities and add them into the drawing, rotate an entity and many more.

DXF and DWG file formats are very popular within the CAD industry; both display vector images; both have the same level of quality and are two common file formats used to exchange information between different CAD and drawing programs. DXF is a semi-public standard promoted and controlled by Autodesk, Inc. DWG is a proprietary, closed format used by Autodesk for its products.

The ACadSharp library is very simple to use and has included various functions for text alignment and formatting, such as aligning text (right, left, center, justify), vertical text alignment (top, middle, bottom), tab indentation, and so on. The ACadSharp library is available under the MIT-License./p>

Previous Next

Getting Started with ACadSharp

The recommended way to install ACadSharp is using NuGet. Please use the following command a smooth installation.

Install ACadSharp via NuGet

 NuGet\Install-Package ACadSharp -Version 1.4.0-alpha 

You can also install it manually; download the latest release files directly from GitHub repository.

Generate AutoCAD DXF/DWG Files via .NET Library

The ACadSharp library has provided complete support for creating and editing CAD DXF & DWG diagrams inside Python applications. It enables software developers create a simple and valid DXF & DWG diagrams with simple entities right now. Work on complex diagram is in progress and will be implemented soon. Developers can write ASCII as well as Binary DXF files with ease.

Create ASCII & Binary DXF File via C# .NET Library

 namespace ACadSharp.Examples
{
	public static class WriterExamples
	{
		/// 
		/// Write a ascii dxf file
		/// 
		/// 
		/// 
		public static void WriteAsciiDxf(string file, CadDocument doc)
		{
			using (DxfWriter writer = new DxfWriter(file, doc, false))
			{
				writer.OnNotification += NotificationHelper.LogConsoleNotification;
				writer.Write();
			}
		}
		/// Write a binary dxf file
		/// 
		/// 
		public static void WriteBinaryDxf(string file, CadDocument doc)
		{
			using (DxfWriter writer = new DxfWriter(file, doc, true))
			{
				writer.OnNotification += NotificationHelper.LogConsoleNotification;
				writer.Write();
			}
		}
	}
}

Manage Entities in CAD Model via C# .NET API

The open source ACadSharp library gives software developers the capability to handle AutoCAD model entities inside their own Python applications. The library has provided several important features for working with model entities, such as Get all the entities in the model, create new entities and add them into the drawing, access and modify entity properties and so on.

Get All Entities in the CAD Model via C# .NET

/// 
/// Get all the entities in the model
/// 
/// 
/// 
public static IEnumerable GetAllEntitiesInModel(string file)
{
	CadDocument doc = DwgReader.Read(file);

	// Get the model space where all the drawing entities are
	BlockRecord modelSpace = doc.BlockRecords["*Model_Space"];

	// Get all the entities in the model space
	return modelSpace.Entities;
}

Access & Read AutoCAD DXF/DWG Files via .NET API

The open source ACadSharp library allows software developers to load and read AutoCAD DXF as well as DWG Files inside their own .NET applications with just a couple of lines of code. To access and read a file first you need to provide the complete path to the DXF as well as DWG Files. Please note that the some modules of DXF/DWG readers are not yet fully implemented and needs further improvement. The NotificationHandler will send a message to inform about the objects that could not be readed or any other error in the process.

Read DXF and DWG Files using C# .NET

 namespace ACadSharp.Examples
{
	public static class ReaderExamples
	{
		/// Read a dxf file
		/// dxf file path
		public static void ReadDxf(string file)
		{
			using (DxfReader reader = new DxfReader(file, NotificationHelper.LogConsoleNotification))
			{
				CadDocument doc = reader.Read();
			}
		}
		/// Read a dwg file
		/// dwg file path
		public static void ReadDwg(string file)
		{
			using (DwgReader reader = new DwgReader(file, NotificationHelper.LogConsoleNotification))
			{
				CadDocument doc = reader.Read();
			}
		}
	}
}