Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History

README.md

Outline

How to use ACadSharp

Quick code samples of how to use ACadSharp

Read and write

Read a dwg file form a path, to read a dxf just change the class DwgReader for DxfReader.

This method allows to attach an event to monitorize the reading process.

/// <summary>
/// Read a dwg file
/// </summary>
/// <param name="file">dwg file path</param>
public static void ReadDwg(string file)
{
	using (DwgReader reader = new DwgReader(file, NotificationHelper.LogConsoleNotification))
	{
		CadDocument doc = reader.Read();
	}
}

Write a CadDocument into a dwg file.

/// <summary>
/// Write a dwg file
/// </summary>
/// <param name="file"></param>
/// <param name="doc"></param>
public static void WriteDwg(string file, CadDocument doc)
{
	using(DwgWriter writer = new DwgWriter(file, doc))
	{
		writer.OnNotification += NotificationHelper.LogConsoleNotification;
		writer.Write();
	}
}

Document exploration

Examples about how to use ACadSharp to create and explore dwg and dxf files.

Quick example of how to get all the entities in the drawing:

/// <summary>
/// Get all the entities in the model
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
public static IEnumerable<Entity> GetAllEntitiesInModel(string file)
{
	CadDocument doc = DwgReader.Read(file);

	// Get the model space where all the drawing entities are
	return doc.Entities;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.