License delivery maintenance is planned for Saturday, July 26, between 12:00 and 20:00 CEST. During this time, you may experience outages or limited availability across our services, including BIMcloud SaaS, License Delivery, Graphisoft ID (for customer and company management), Graphisoft Store, and BIMx Web Viewer. More details…
2023-10-21
07:44 AM
- last edited on
2024-09-16
02:38 PM
by
Doreena Deng
hi guys,
Do you know how to get active view?
(I think I need to use API_NavigatorItem, But I couldn't do it)
If you know, please help me
Thank you very much
2023-10-24 11:14 PM
Hi,
There's no function to get the active view directly as far as I know.
But you can workaround this with using with a View Notification Handler.
You have to register the notification handler in the Initialize function:
ACAPI_Notify_CatchViewEvent (APINotifyView_Opened, API_MyViewMap, ViewNoticationHandlerProc);
This has to be done separately for every API_NavigatorMapID you need. So you'll have to use a bit of trial and error to figure out which ones you'll need.
And the handler would look something like this:
static GSErrCode __ACENV_CALL ViewNoticationHandlerProc (const API_NotifyViewEventType* viewEvent)
{
switch (viewEvent->notifID) {
case APINotifyView_Opened: {
// Do something here with `viewEvent->itemGuid`
break;
}
default: break;
}
return NoError;
}
Also the Add-On needs to be registered as a preloaded Add-On. So return API_Addon_Preload in CheckEnvironment.
Hope that helps!
Bernd
2023-10-30
02:39 AM
- last edited on
2023-10-30
03:52 AM
by
Laszlo Nagy
Hi @Bernd - Archi-XT ,
I followed your tutorials, but it still doesn't work? Can you check and tell me where I'm wrong
This is my code:
API_AddonType __ACENV_CALL CheckEnvironment(API_EnvirParams* envir)
{
RSGetIndString(&envir->addOnInfo.name, ID_ADDON_INFO, 1, ACAPI_GetOwnResModule());
RSGetIndString(&envir->addOnInfo.description, ID_ADDON_INFO, 2, ACAPI_GetOwnResModule());
return APIAddon_Preload;
}
static GSErrCode __ACENV_CALL ViewNoticationHandlerProc(const API_NotifyViewEventType* viewEvent)
{
switch (viewEvent->notifID) {
case APINotifyView_Opened: {
// Do something here with `viewEvent->itemGuid`
WriteReport_Alert("View");
break;
}
default: break;
}
return NoError;
}
GSErrCode __ACENV_CALL Initialize(void)
{
GSErrCode err = ACAPI_Install_MenuHandler(ID_MENU_STRINGS, MenuCommandHandler);
API_NavigatorMapID mapId = API_MyViewMap;
ACAPI_Notify_CatchViewEvent(APINotifyView_Opened, mapId, ViewNoticationHandlerProc);
if (err != NoError)
DBPrintf("3D_Test:: Initialize () ACAPI_Install_MenuHandler failed\n");
return err;
} // Initialize
2023-10-31 10:35 AM
Hi @Bernd - Archi-XT , Can you help me?
2023-10-31 10:40 AM
I'm quite busy right now, but tomorrow I'll have more time to take a closer look.
Please specify what exactly is not working.
What did you try to do in the program and what did you expect to happen?
From a quick look at the code it seems OK. Maybe try different NavigatorMapIDs like API_ProjectMap, API_UndefinedMap, API_PublicViewMap.
2023-11-04 09:58 AM
I did a few quick tests by opening different view maps in Archicad and checking which map ID is used in the triggered view notification.
Here's the mapping of Archicad Navigator Map -> API_NavigatorMapIDs when listening to APINotifyView_Opened:
Couldn't find anything that triggered the API_MyViewMap. I'm sure I used it before for something, but can't remember now.
Hope that helps,
Bernd