Active Contributor
Posts: 47
Registered: ‎12-03-2009
Message 1 of 2 (475 Views)

How to use Export API for autocad document object?

475 Views, 1 Replies
09-12-2012 11:49 PM

 void Export([In, MarshalAs(UnmanagedType.BStr)] string FileName, [In, MarshalAs(UnmanagedType.BStr)] string Extension, [In, MarshalAs(UnmanagedType.Interface)] AcadSelectionSet SelectionSet);


Who can tell me how to use Export API?


Autodesk.AutoCAD.Interop.AcadApplicationClass acadApp = null;
acadApp = new Autodesk.AutoCAD.Interop.AcadApplicationClass();
if (acadApp != null)
string dwgFileName = @"C:\Test.dwg";
Autodesk.AutoCAD.Interop.AcadDocument document = acadApp.Documents.Open(dwgFileName);

catch (Exception ex)
if (acadApp != null)

ADN Support Specialist
Posts: 666
Registered: ‎03-21-2011
Message 2 of 2 (437 Views)

Re: How to use Export API for autocad document object?

09-18-2012 05:15 AM in reply to: yuh0317



Here is a sample code directly migrated from the ActiveX documentation (acadauto.chm).


public void ExportMethod()
	Document doc = Application.DocumentManager.MdiActiveDocument;
	Editor ed = doc.Editor;
	AcadDocument acadDoc = doc.AcadDocument as AcadDocument;

	// This example exports the current drawing to DXF format.
	// Note that a valid selection set must be provided, even
	// though the contents of the selection set are ignored.

	// Define the name for the exported file
	string exportFile = null;
	exportFile = "C:\\Temp\\DXFExprt.dxf";
	// Adjust path to match your system

	// Create an empty selection set
	AcadSelectionSet sset = default(AcadSelectionSet);
	sset = acadDoc.SelectionSets.Add("TEST");

	// Export the current drawing to the file specified above.
	acadDoc.Export(exportFile, "DXF", sset);

 Hope this helps.

Developer Technical Services
Autodesk Developer Network

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community