What you suggest does not work, because changes
to a drawing can be undone without any commands
starting or ending.
For example, right-click on the Properties palette
and choose "Undo".
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009
http://www.acadxtabs.com
Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm
wrote in message news:6033553@discussion.autodesk.com...
Tony's idea is very sound, in fact my team practices it as well. However if you wish to attempt a tracking of the Undo command to possibly roll back some changes you made, you need to follow some not so simple steps:
Listen to CommandWillStart
filter for e.GlobalCommandName to get the "U" undo command name, then flag it.
IF flagged, then collect object ID's processed by the Undo command
Listen to the EnteringQuiescentState
If your undo flag was set, then process the undo IDs for something that is of your project (a block reference you created for example)
If one of your objects was found, then goto town on it...
Clear your undo flag.
Here is a snippet of my code and all the Events that I listen too when processing an Undo command:
Private Sub callback_CommandWillStart(ByVal sender As Object, ByVal e As CommandEventArgs)
If booIgnoreCommandWillStart Then Exit Sub
'Debug.Print("CWS: " & e.GlobalCommandName)
'Dim ibe As Boolean = Me.IgnoreEvents
Try
Select Case e.GlobalCommandName
Case "U"
IgnoreEvents = True 'listen to no events
booIgnoreObjectModified = False 'ensure object modified is listening
booIgnoreObjectAppended = False
booIgnoreObjectErased = False
booIgnoreObjectReappended = False
booIgnoreObjectUnappended = False
booUndo = True 'turn on the undo flag so we collect IDs instead of process them actively
booIgnoreCommandEnded = False 'turn on the command ended to listen so it can deactivate these events
That's about it, but it takes a lot of code, practice, and patience. Good luck.
jvj