Learn to manage BIM workflows and create professional Archicad templates with the BIM Manager Program.

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

How to Preserve Global Variables in an Archicad 27 Add-On?

nishida_jp
Booster

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?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Solution

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)

Ralph Wessel BArch
Central Innovation

View solution in original post

Solution

I really appreciate your help!

GSErrCode Initialize (void){
//...
ACAPI_KeepInMemory(true);
return(err);
}

static GSErrCode MenuCommandHandler (const API_MenuParams *menuParams)
{
ACAPI_KeepInMemory(true);
//...
}

View solution in original post

2 REPLIES 2
Solution

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)

Ralph Wessel BArch
Central Innovation
Solution

I really appreciate your help!

GSErrCode Initialize (void){
//...
ACAPI_KeepInMemory(true);
return(err);
}

static GSErrCode MenuCommandHandler (const API_MenuParams *menuParams)
{
ACAPI_KeepInMemory(true);
//...
}

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!