We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2021-10-09 08:32 AM
Hi
Is there any notification of the change in Story settings that can be captured by an add-on?
I tried:
ACAPI_Notify_CatchProjectEvent (API_AllProjectNotificationMask, NotificationHandler);
and tried capturing the notification ID "APINotify_ChangeFloor" but that doesn't trigger upon adding or removing a story in the project from 'Story settings'.
How can I capture the addition/deletion/rename of stories in the project?
Thanks.
2021-10-11 11:45 AM
I haven't tried it myself, but I saw something in the Documentation of APIProjectEventHandlerProc. It seems like you can catch "APINotify_ChangeProjectDB" and if the "param" parameter of your handler callback has value 1 it means that the floors changed.
2021-10-11 02:40 PM
I tried that, but adding/deleting floors does not pass notifID as "APINotify_ChangeProjectDB".
2021-10-12 11:35 AM
Hm.. that's weird. I tried it now also and it seems to work for me.
Here are the relevant code sections I used:
static GSErrCode __ACENV_CALL ProjectEventHandlerProc (API_NotifyEventID notifID, Int32 param)
{
switch (notifID) {
case APINotify_ChangeProjectDB:
{
DG::InformationAlert ("Change project DB", "param: " + GS::ValueToUniString (param), "OK");
break;
}
default: break;
}
return NoError;
}
GSErrCode __ACENV_CALL Initialize (void)
{
GSErrCode err = NoError;
err = ACAPI_Notify_CatchProjectEvent (APINotify_ChangeProjectDB,
ProjectEventHandlerProc);
return err;
}
All three actions: Remove/Add/Rename Floor trigger the "APINotify_ChangeProjectDB" with "param = 1" for me.
2021-10-12 11:51 AM - edited 2021-10-12 01:01 PM
Where is ProjectEventHandlerProc being called from?
EDIT: Sorry, I didn't scroll your code 🙂
So this is what's happening:
I was passing API_AllProjectNotificationMask to the callback, assuming that it would capture _all_ the events, as I needed to capture another event, like so:
ACAPI_Notify_CatchProjectEvent (API_AllProjectNotificationMask, NotificationHandler);
But it seems it does not.
I tried passing APINotify_ChangeProjectDB directly and it worked!
That's strange because the example on https://archicadapi.graphisoft.com/documentation/apiprojecteventhandlerproc shows the case for APINotify_ChangeProjectDB ... Don't know what I'm missing here.
Anyway, now I have created separate calls for each event.
Thanks Bernd!
2021-10-12 01:25 PM
Glad it works now for you too 🙂
Yes "API_AllProjectNotificationMask" doesn't include "APINotify_ChangeProjectDB". You can check the values of the mask in the AC API header "APIdefs_Callback.h". Here's the relevant part:
#define API_AllProjectNotificationMask 0x00000FFF // APINotify_New..APINotify_ConvertGuid
#define API_AllTeamWorkNotificationMask 0x00018000 // APINotify_Share..APINotify_ChangeWorkspace
#define API_AllChangeNotificationMask 0x033C0000 // APINotify_ChangeProjectDB..APINotify_ChangeFloor
#define API_AllNotificationMask 0xFFFFFFFF
The example you linked probably uses "API_AllNotificationMask". You can also select multiple notifications by combining them with "OR" like this:
APINotify_ChangeProjectDB | APINotify_SomeOtherMask | ....
2021-10-12 01:48 PM - edited 2021-10-12 01:49 PM
I gave a different ref. link last time, which doesn't have the function call. Check out the example here: https://archicadapi.graphisoft.com/documentation/acapi_notify_catchprojectevent?s=ACAPI_Notify_Catch...
It passes API_AllProjectNotificationMask , and shows the case for APINotify_ChangeProjectDB.
@BerndSchwarzenbacher wrote:You can also select multiple notifications by combining them with "OR"
That's interesting. Thanks! 👍
2021-10-12 04:03 PM
You are right. That example is very misleading!