Description
In our previous article we have made a live connection with Autocad. We create a class called “AutocadConnection”.
In this article we will query the document using a console application and we will print out some information regarding our open Autocad application.
Code
class Program
{
static void Main(string[] args)
{
AutocadConnection Connection = new AutocadConnection();
AcadApplication acApp = Connection.Application;
if (acApp != null)
{
Console.WriteLine(acApp.Application.ActiveDocument.ActiveLayer.Name);
Console.WriteLine(acApp.Name);
Console.WriteLine(acApp.ActiveDocument.Name);
Console.WriteLine(acApp.ActiveDocument.ModelSpace.Name);
AcadLayouts layouts = acApp.ActiveDocument.Database.Layouts;
IEnumerator enumerator = layouts.GetEnumerator();
while (enumerator.MoveNext())
{
Console.WriteLine($"Layout: {((AcadLayout)enumerator.Current).Name}");
}
AcadDocuments Documents = Connection.Application.Documents;
var enumerator2 = Documents.GetEnumerator();
while (enumerator2.MoveNext())
{
Console.WriteLine($"Document : {((AcadDocument)enumerator2.Current).Name}");
}
}
}
}
Result









