Cancel
Showing results for 
Search instead for 
Did you mean: 

EventHandler for delete entities in OperationTree

Creator
Creator

Hi,

 

Is there a EventHandler for deleteing in the OperationTree?

 

i've tried:

TxApplication.ActiveDocument.PhysicalRoot.Deleted 
TxApplication.ActiveDocument.PhysicalRoot.ItemsRemoved 

TxApplication.ActiveDocument.UpdateEnded 
TxApplication.CommandsManager.CommandExecuted 

 

but no reaction!

 

Thanks.

2 REPLIES

Re: EventHandler for delete entities in OperationTree

Siemens Genius Siemens Genius
Siemens Genius

Hi.

you can register to the delete event of the operation.

first you need to collect all the operations that you want to track. Use the filtering mechnism for that. In order to get  all the operation in the study, use the NoTypeFilter, e.g:

 

         TxObjectList list = TxApplication.ActiveDocument.OperationRoot.GetAllDescendants(new TxNoTypeFilter());

 

 

and then you should register for the delete event:

 

        foreach (var obj in list)
        {
	    obj.Deleted+=ItemIsaboutToBeRemoved;
	}
  }
public void ItemsIsAboutToBeRemoved( object sender, TxObject_DeletedEventArgs rgs) { //do something }

This event is fired before the actual delete is done, so you can access the "almost" deleted operation and get info about it.

don't forget to unregister this operation from the handler. 

 

Re: EventHandler for delete entities in OperationTree

Creator
Creator

Wokrs! Big Thanks!