BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

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

[SOLVED] Automatically starting add-on(notification handler)

Anonymous
Not applicable
Hi

Is it possible to start add-on automatically?

I want to use some events (APINotify_New, APINotify_Open, APINotify_Close).

I've added

GSErrCode __ACENV_CALL	Initialize (void)
{
...
    GSErrCode err = ACAPI_Notify_CatchProjectEvent (API_AllProjectNotificationMask, NotificationHandler);

...
}
on Initialize and I've added notification handler:

static GSErrCode __ACENV_CALL    NotificationHandler (API_NotifyEventID notifID, Int32 param)
{
    switch (notifID) {
        case APINotify_New:
...
        case APINotify_Open:
...
    }
}
Problem is with Initialize method, it isn't executed automatically after ArchiCAD starts.
If I add menu command handler, Iinitialize method will be executed on user's menu action (first time).

Is it possible to run add-on automatically (start Notification handler) without user action?

Thanks

Lukasz
2 REPLIES 2
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
Hi Lukasz,
Lukasz wrote:
Problem is with Initialize method, it isn't executed automatically after ArchiCAD starts.

Please check the return type of your CheckEnvironment function!
I think you should return APIAddon_Preload in CheckEnvironment function. That way Initialize method will be executed when ArchiCAD starts.
Using ACAPI_KeepInMemory could be necessary also.

Regards,
Tibor
Anonymous
Not applicable
Great! Thanks Tibor. It is working

Best Regards
Lukasz
Learn and get certified!