Saving Add-On data into the Preferences and the Project File


This paper give hints on how to save own data into the preferences and the actual project file.

 

Possibilities

You are allowed to save an unlimited number of bytes into the preferences file. The preferences data is also stored in in all project files.

Preferences data saved into a project makes it possible to open a saved project file with the same working environment. It is also used to open dialog boxes with the same settings as they had when they were closed, even if you do not quit the application.

If your add-on uses settings which should be preserved, please use this feature.

You can save your data into the preferences file using the ACAPI_SetPreferences function and retrieve the stored preferences with ACAPI_GetPreferences.

When the server application starts with a new plan, the preferences data of the add-on is available previously saved into the preferences file of the application. If you open a plan file which has preferences data stored into it by your add-on, this data overwrites the current preferences of the add-on, that is, the add-on preferences can be changed after opening a project. Remember this if you need to maintain preferences data consistency in your add-on.

6.1  If your add-on has different versions of preferences data in different program releases, it is recommended to set the preferences of the older formats as well in order to ensure backward compatibility. Use the ACAPI_SetPreferences_OldVersion function (ARCHICAD only) to define your data to be saved into the specified (and earlier) plan versions instead of saving the current preferences version.

It is also important to handle platform specific data if the preferences can come from a plan file saved on the other platform. Use the ACAPI_GetPreferences_Platform function instead of ACAPI_GetPreferences to retrieve the platform information too. If the platform identifier of the stored preferences does not match the actual platform, convert the data to the appropriate format.

 

Notes

Please study the source code of the DG Test example to see the suggested way of handling the preferences data.