Updated to show how to run code each time a document is opened or a new document is created.
using System;
using System.Collections.Generic;
using System.Text;
using AcAp = Autodesk.AutoCAD.ApplicationServices;
using AcDb = Autodesk.AutoCAD.DatabaseServices;
using AcRx = Autodesk.AutoCAD.Runtime;
namespace ClassLibrary1
{
public class Class1 : AcRx.IExtensionApplication
{
public void DocumentAdded(object sender,AcAp.DocumentCollectionEventArgs e)
{
//Add code here that should run each time a drawing is opened
//or a new one is created.
AcAp.Application.ShowAlertDialog("A new document was added");
}
#region IExtensionApplication Members
public void Initialize()
{
//Add Code here that you wish to run when the program is loaded
AcAp.Application.DocumentManager.DocumentCreated += new AcAp.DocumentCollectionEventHandler(DocumentAdded);
}
public void Terminate()
{
//This method must exist, but is never called
}
#endregion
}
}
Ronnie Wilkins, Jr.