Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

Is it possible to be notified when a element gets deleted outside observed elements?

Joel Buehler
Enthusiast

Maybe thats a dumb question:

 

we can get a notification when a element gets deleted that has the ElementObserver installet to it with the API Call "ACAPI_Element_InstallElementObserver"

 

the documentation and the Notification_Manager example imply that it is only possible to be notified when a element gets deleted when the observer is attached to a element. 

 

is there really no other way to get notified when a element gets deleted? 

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Hi Joel!

You could install the necessary element observers by iterating through all elements you want to be notified for when opening the project. Make sure to handle the case when an observer is already installed for an element.
Or is there something blocking you from doing this?

 

Best,
Bernd

View solution in original post

5 REPLIES 5
kolioi
Booster

Check out the Notification_manager example add-on. You can handle all types of notifications.

are you sure the example is able to get a notification of a deleted element that has been created before the ACAPI_Element_CatchNewElement Callback has been hooked? 

 

JoelBuehler_0-1702589162475.png

both walls get deleted

JoelBuehler_2-1702589243510.png

Only one deletion can be seen in the Element Manager:

 

JoelBuehler_1-1702589221525.png

 

From my understanding it is not possible to get any changes of elements that have been created bevore element callback methods have been setup. from my point of view defeats this functionallty the purpose of a element callback system. furthermore would this mean that the element callback system is not consistent to other callback systems like the  Project Operation- or the Selection Callbacks, they can catch any changes made to the database. 

 

 

 

Solution

Hi Joel!

You could install the necessary element observers by iterating through all elements you want to be notified for when opening the project. Make sure to handle the case when an observer is already installed for an element.
Or is there something blocking you from doing this?

 

Best,
Bernd

Hehey Bernd

 

Thank you for your answer. thats waht i thought that i have to do but i was not sure if i missed something. now i know for sure 😄 

the problem i have is, that a iteration trough the database is time consuming and freezeses the gui 😞 

 

Yeah that's the unfortunate side effect 😣
In case you haven't used it before, there's a way to show a progress window which at least lets the user know how long it'll take. There's some sample code for it in the DG_Test example.