How to Get all opened AutoCad documents(drawings) using .NET

vinayan picture vinayan · May 28, 2012 · Viewed 9.6k times · Source

I am using AutoCAD 2012 and the .NET API. Can someone help me how can i loop through the document objects of all the open documents? i am trying to do something like the code below..I have this question on Autodesk Forum too..but not sure how much active it is :)

public void GetDocNames()
        {
            DocumentCollection docs = Application.DocumentManager;

            for (int i = 0; i < docs.Count; i++)
            {
                AcadDocument doc = docs[i];
                Debug.Print(doc.Name);
            }
        }

Answer

JayP picture JayP · May 29, 2012

You have tagged both C# and VB.NET. The C# version is as follows:

public void GetDocNames()
{
  DocumentCollection docs = Application.DocumentManager;

  foreach (Document doc in docs)
  {
    Application.ShowAlertDialog(doc.Name);
  }
}