2026-02-07 07:25 PM
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
Solved! Go to Solution.
2026-02-11 11:21 AM
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
2026-02-11 11:21 AM
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
2026-02-16 07:59 PM - edited 2026-02-17 09:32 AM
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