We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

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

Capture the change (addition/deletion/rename) of Story Settings

dushyant
Enthusiast

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.

7 REPLIES 7

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.

 

I tried that, but adding/deleting floors does not pass notifID as "APINotify_ChangeProjectDB".

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.

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!

 

 

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 | ....

 

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! 👍

You are right. That example is very misleading!