You are here:

AutoCAD/Code reopen current drawing


Mr. R, i've been using autocad for several years now. I also know the basic concept of programming in autolisp. However, I've been reading up on c# & recently purchased my book & copy of Visual Studio. Very intimidating I might add. I'm looking for a simple code in c# for autocad to reopen the current drawing (disregarding any changes to its dbase & not saving any data at all). I'm still not sure how to start the code but anything you can provide I can surely dissect and learn from. Thank you for your time.

-Best regards,

Hi Mike,

First you need create the Project of type Class Library and take the below mentioned dlls as reference which are exist in AutoCAD installation folder or Object ARX SDK installed folder.


Before using the below code please go through the SDK Help documents which gives you more information.

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;

public static void OpenDrawing(string strFileName )
 DocumentCollection acDocMgr = AcadApp.DocumentManager;

 if (File.Exists(strFileName))
     acDocMgr.Open(strFileName, false);
     acDocMgr.MdiActiveDocument.Editor.WriteMessage("File " + strFileName +
         " does not exist.");

public void CloseDrawing()
  Document oDoc = AcadApp.DocumentManager.MdiActiveDocument as Document;

The above code is not tested. I am not having the environment.

The remain things you can get from the documents available with the Object ARX SDK. I think this will provide you a start with AutoCAD with c#. Still you need any information...don't hesitate to post me a question.


All Answers

Answers by Expert:

Ask Experts


Ramanjaneyulu .J


Any doubts bound to AutoCAD Customization with AutoLISP, VLISP, VBA, Objectarx and also with C#


I hold experience in the GIS industry in delivering the customized breakthroughs for the below products. AutoCAD AutoCAD Map AutoCAD Overlay

Cyient(Infotech Enterprises Ltd) (Current) Avineon India Pvt Ltd DSM soft Alcor Technologis Pvt Ltd

Diplioma in Mechanical Engineering

©2017 All rights reserved.

[an error occurred while processing this directive]