cancel
Showing results for 
Search instead for 
Did you mean: 
EN
cancel
Showing results for 
Search instead for 
Did you mean: 
kuvbur
Advocate

Persisting GS::Array<API_Neig> between SelectionChangeHandlerProc and ProjectEventHandlerProc

How to persist GS::Array<API_Neig> between SelectionChangeHandlerProc and ProjectEventHandlerProc in ArchiCAD add-on? I want to save selection when switching windows (floor plans/sections). In SelectionChangeHandlerProc I capture selection with ACAPI_Selection_Get() into GS::Array<API_Neig>, then in ProjectEventHandlerProc catch APINotify_ChangeWindow/ChangeFloor/ChangeProjectDB and restore with ACAPI_Element_Select(). Problem: can't reliably pass array between callbacks. Tried global variables, static locals, singleton — all fail between invocations. What's the standard way to share data between ArchiCAD notifier callbacks?

Industrial Architect and Structural Design Engineer, developer of free addon for sync GDL param and properties

1 Solution

Accepted Solutions

I suggest taking a look at the API call  ACAPI_KeepInMemory. Add-ons are unloaded from memory when not in use by default, which means they lose all variable data between one call and the next. But if you call ACAPI_KeepInMemory(true) you ask Archicad to persist the add-on in memory for the entire session, which means variable contents also persists between calls

Ralph Wessel BArch
Central Innovation

Go to post

2 Replies 2

I suggest taking a look at the API call  ACAPI_KeepInMemory. Add-ons are unloaded from memory when not in use by default, which means they lose all variable data between one call and the next. But if you call ACAPI_KeepInMemory(true) you ask Archicad to persist the add-on in memory for the entire session, which means variable contents also persists between calls

Ralph Wessel BArch
Central Innovation
kuvbur
Advocate

Thank you for your suggestion regarding ACAPI_KeepInMemory(true). I tried implementing it, but the data only persists within one Database. As soon as I switch to another window (e.g., from floor plan to section), the data in the array gets cleared.

Could you please advise on the correct approach?

I found a bug in my code — everything works perfectly now! Thank you so much for the helpful suggestion!

Industrial Architect and Structural Design Engineer, developer of free addon for sync GDL param and properties

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!