Hi All
I'm trying to have AutoCAD call a function (resetVariables) when a new drawing is opened. Currently, AutoCAD loads fine, NETLOAD is successful, and I can run several other commands from the same code, but when I open a drawing, the drawing loads then immediately gives an AutoCAD "FATAL ERROR".
My code is posted below; any insight would be greatly appreciated.
{code}
public class Init : Autodesk.AutoCAD.Runtime.IExtensionApplication
{
Database db = HostApplicationServices.WorkingDatabase;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
public void Initialize()
{
// Notify the user of the start of initialization
ed.WriteMessage("\nIMine Initialization... ");
// Set system variables in accordance with mine standards
Application.SetSystemVariable("MENUECHO", 1);
Application.SetSystemVariable("SDI", 1);
Application.SetSystemVariable("PSLTSCALE", 0);
// Start a callback function to detect the opening of a new drawing
Application.DocumentManager.DocumentActivated +=new DocumentCollectionEventHandler(resetVariables);
// Notify the user of completion of initialization
ed.WriteMessage("Complete!\n");
}
public void Terminate(){}
public void resetVariables(object sender, DocumentCollectionEventArgs e)
{
ed.WriteMessage("\nIntercepted a DocumentCollection event");
}
}
{code}
- Iain