Document.ObjectReappended , how it work?

Document.ObjectReappended , how it work?

joantopo
Mentor Mentor
549 Views
4 Replies
Message 1 of 5

Document.ObjectReappended , how it work?

joantopo
Mentor
Mentor

I have this:

 

    doc.Database.ObjectReappended += new ObjectEventHandler(MainForm.callback_ObjectReAppended);

And I have a break point in Visual Studio in the "callback_ObjectReAppended" method, but I remove some objects of the drawing and then press "UNDO"  (CTRL+Z) but there is no way to fire this event.

 

 

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
0 Likes
550 Views
4 Replies
Replies (4)
Message 2 of 5

norman.yuan
Mentor
Mentor

Here is what the ObjectARX Document says on Database.ObjectReappended event:

 

Wraps AcDbDatabaseReactor::objectReAppended. The event is invoked when an object has had its addition to the database dwg undone during an Undo operation, and has now been re-appended to the database due to an execution of the AutoCAD REDO command.

 

It looks like, your event handler would be called only when REDO command is executed AND when there is object is unappened by UNDO command (i.e. there is object was appended to database prior to UNDO command execution). So, your described scenario (erasing something from database and then using UNDO command to get them back) probably not triggers Database.Reappended event, according to the document's description.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 5

joantopo
Mentor
Mentor

Exactly.

 

I remove an object and then I do UNDO, that event was wrong for this scenario but I don´t know what event use for this.

 

 

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
0 Likes
Message 4 of 5

Jeff_M
Consultant
Consultant

The ObjectErased event fires when the object is erased, AND when it is Unerased (UNDO & Oops both fire this).

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 5 of 5

joantopo
Mentor
Mentor

Hi Jeff.

Yes, your comment is right and I am using it in my LAM addon.

 

But there is the following scenario when ObjectErased is not triggered.

 

You create an alignment, then you do some operations. 

If you do MULTIPLE Undo until the alignment dissapears in the drawing, then ObjectErased event is not fired.

 

 

I have a bool global variable called "UNDO_afterErased=false; that I put it within the method of ObjectErased event and then this variable is true.

 

Also, I have the CommandEnded event: 

 

  public static void doc_CommandEnded(object sender, CommandEventArgs e)
        {
          
            if (e.GlobalCommandName == "UNDO")  //ES EL UNDO
            {

                if (variables.UNDO_afterErased== false)
                {
                    //hacer las operaciones
                 
                }
                else //si es true ponerlo de nuevo a false
                {
                    variables_globales.UNDO_afterErased = false;
                }
            }
}

I am following this thread:

http://adndevblog.typepad.com/autocad/2013/01/monitoring-object-during-undoredo-with-net-api.html

 

 

So, when the UNDO doesn´t fire ObjectErased Event, (I have to check with ObjectReappended event if the recover entity is really an alignment type and update my XRecord and array var.

 

When ObjectErased is fired, there is no problem because the XRecord is updated automatically.

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
0 Likes