.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Reply
Message 1 of 5
Anonymous
816 Views, 4 Replies

Undo event

Is there any way to catch the Autocad undo event? Well, actually what I'm interested in is if a particular object gets restored in a drawing due to the user undoing an erase. Scenario is: I have an object, a user deletes it (I can catch the ObjectErased event and check the e.DBObject property), then the user clicks undo, the object comes back but the problem is it doesn't generate any ObjectAppended or ObjectModified events. How can I get a reference to that object? Is there a reactor to undo or something I can use? What event does this operation fire? Thank you.
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

The ObjectModified event fires when a change is
made to an object, including when changes are
undone, so what you say below is not the case,
the ObjectModified event fires when an erase is
undone.

You should be aware that in AutoCAD 2008, a
bug exists that makes it impossible to remove
a database event handler. You can remove the
handler from the event, but the event continues
to fire the handler.

You can look at the IsUndoing property of the
DBObject passed into the event args, to see if
the change is caused by undo.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5676875@discussion.autodesk.com...
Is there any way to catch the Autocad undo event? Well, actually what I'm interested in is if a particular object gets restored in a drawing due to the user undoing an erase. Scenario is: I have an object, a user deletes it (I can catch the ObjectErased event and check the e.DBObject property), then the user clicks undo, the object comes back but the problem is it doesn't generate any ObjectAppended or ObjectModified events. How can I get a reference to that object? Is there a reactor to undo or something I can use? What event does this operation fire? Thank you.
Message 3 of 5
Anonymous
in reply to: Anonymous

Undoing an erase doesn't fire an ObjectModified event, probably because erasing doesn't either so it wouldn't make sense. The event is fired if undoing changes to the object like moving or scaling it. Maybe an ObjectUnerased event of some sort?

Check this out (by the way, I'm using VS 2005 and AutoCAD 2006):

Public Class HandlerTest
Implements Autodesk.AutoCAD.Runtime.IExtensionApplication

Dim WithEvents acadDB As Database = HostApplicationServices.WorkingDatabase

Public Sub Initialize() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize
AddHandler acadDB.ObjectModified, AddressOf ObjectModified
End Sub

Public Sub Terminate() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Terminate

End Sub

Public Sub ObjectModified(ByVal sender As Object, ByVal e As ObjectEventArgs)
If TypeOf e.DBObject Is Entity Then
MsgBox(e.DBObject.GetType.ToString & " has been modified.")
End If
End Sub

End Class


Draw something and play around with it, erase it and undo that, the message box won't show up.
Message 4 of 5
Anonymous
in reply to: Anonymous

Sorry, I was mistaken.

It is not the ObjectModified handler that fires when you
undo the erase of an object, it is the ObjectErased handler
that fires (with the Erased property of the event args set
to false).

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5678006@discussion.autodesk.com...
Undoing an erase doesn't fire an ObjectModified event, probably because erasing doesn't either so it wouldn't make sense. The event is fired if undoing changes to the object like moving or scaling it. Maybe an ObjectUnerased event of some sort?

Check this out (by the way, I'm using VS 2005 and AutoCAD 2006):

Public Class HandlerTest
Implements Autodesk.AutoCAD.Runtime.IExtensionApplication

Dim WithEvents acadDB As Database = HostApplicationServices.WorkingDatabase

Public Sub Initialize() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize
AddHandler acadDB.ObjectModified, AddressOf ObjectModified
End Sub

Public Sub Terminate() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Terminate

End Sub

Public Sub ObjectModified(ByVal sender As Object, ByVal e As ObjectEventArgs)
If TypeOf e.DBObject Is Entity Then
MsgBox(e.DBObject.GetType.ToString & " has been modified.")
End If
End Sub

End Class


Draw something and play around with it, erase it and undo that, the message box won't show up.
Message 5 of 5
Anonymous
in reply to: Anonymous

Yes it does, thanks.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report