Author Topic: DocumentCollection Event Handler(s)  (Read 14106 times)

0 Members and 1 Guest are viewing this topic.

BillZndl

  • Guest
Re: DocumentCollection Event Handler(s)
« Reply #30 on: September 26, 2012, 07:29:18 AM »
Would'nt Autocad have to be closing if your app is closing?
I'm not sure what you mean by 'close my app'.

Just to clarifly:

My "App" netloads and shows a modeless form and populates a listview with the names of any AutoCAD "Groups" that exist in the drawing.
The command and database event handlers watch for when new groups are added to the database and adds a "date created" to the description field of the group.

The "App" runs off an "instance" of the form and I override the "OnClosing" event where the visibility of the form is set to false,
so I think the App really doesn't "Close" until AutoCAD closes.

Code: [Select]
private static PartMonitor instance = null;

public static PartMonitor Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new PartMonitor();
                }
                return instance;
            }
        }

protected override void OnClosing(CancelEventArgs e)
        {           
                base.OnClosing(e);
                e.Cancel = true;
                Visible = false;       
        }
////
public class PartMonitor1
    {       
        [CommandMethod("Partmon", CommandFlags.Session)]   
        public static void ShowModelessDialog()
        {
            Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog(PartMonitor.Instance);
        }       
    }

Yes, if they have overhead. The Command-related events can have overhead especially when commands are being scripted at a high-frequency by other customization, namely LISP.
The way you're doing it with the Command events is IMO, the right way to do it, since you don't want your event handlers called when every command is ended/cancelled.

Thank you!
That was the thought process that led me to set up the event handlers that way.