How to Preserve Global Variables in an Archicad 27 Add-On?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2025-03-17 04:47 AM
I'm developing an add-on using the API in Archicad 27 with Visual C++ 2019 on Windows 10.
The add-on uses global variables to store calculated data in memory. When I run the add-on from the menu, the calculated results are stored in the add-on's memory. However, when I open the menu and run the add-on again, the previously stored values are lost.
How can I prevent this from happening?
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2025-03-17 01:12 PM
The default behaviour is for Archicad to unload an add-on from memory when it isn't in use, which will cause any data held by the add-on to be lost. You can prevent an add-on from being unloaded by calling ACAPI_KeepInMemory(true)
Central Innovation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2025-03-18
03:15 AM
- last edited on
ā2025-03-19
04:51 PM
by
Laszlo Nagy
I really appreciate your help!
GSErrCode Initialize (void){
//...
ACAPI_KeepInMemory(true);
return(err);
}
static GSErrCode MenuCommandHandler (const API_MenuParams *menuParams)
{
ACAPI_KeepInMemory(true);
//...
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2025-03-17 01:12 PM
The default behaviour is for Archicad to unload an add-on from memory when it isn't in use, which will cause any data held by the add-on to be lost. You can prevent an add-on from being unloaded by calling ACAPI_KeepInMemory(true)
Central Innovation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2025-03-18
03:15 AM
- last edited on
ā2025-03-19
04:51 PM
by
Laszlo Nagy
I really appreciate your help!
GSErrCode Initialize (void){
//...
ACAPI_KeepInMemory(true);
return(err);
}
static GSErrCode MenuCommandHandler (const API_MenuParams *menuParams)
{
ACAPI_KeepInMemory(true);
//...
}