I have a counter which write to drawing extended dictionary after creating object withing code.
let's say for any line which is being created by program. counter will add up.
Now if user make undo, Undo command doesn't change that counter in Dic. Didn't know this. I thought I have to write an
Event handler. But I thoguht maybe easier way. I am not really good with events and reactor.
Any Suggestion from Experts Would be appreciated .
The first thought to come to mind is,
You could keep a collection of ObjectIds that you add and use the Database.ObjectUnappended Event to check if your collection contains it and if so remove it and subtract the counter
If you need to keep up with redo's then have another collection that you add the removed Ids to and do the reverse for
Database.ObjectReappended Event
or
if you only need to check between saves you could use a save event and check ObjectID.IsErased property
Thanks Jeffrey for your time. I am going to work on your suggestion. But like I said I don't feel comfortable to work with those events. I guess no other choice. Cheers.
I would see what others say but if you do not want to mess with events(one day you will) I guess even though it will increase the size some is to add a entry in each objects ExtensionDictionary that you create, and when you want the count all you have to do is itterate BlockTableRecords where IsLayout is true and check for the entry.
I guess you would also need consider per document counting. There are examples of per doc at the Swamp.