Archicad 28 C++ API
|
Functions for creating, handling and deleting custom (Add-On specific) preferences, which get stored in the project file. Useful for storing Work Environment settings or some inner states of the Add-On which can be read at the next opening of the project. More...
Functions | |
GSErrCode | ACAPI_SetPreferences (Int32 version, GSSize nByte, const void *data) |
Saves custom preferences data into the preferences file. | |
GSErrCode | ACAPI_GetPreferences (Int32 *version, GSSize *nByte, void *data) |
Returns the stored preferences of the add-on. | |
GSErrCode | ACAPI_Preferences_Platform (Int32 *version, GSSize *nByte, void *data, unsigned short *platformSign) |
Returns the stored preferences of the add-on. | |
GSErrCode | ACAPI_Preferences_SetOldVersion (Int32 version, GSSize nByte, const void *data, unsigned short platformSign, API_FTypeID oldPlanFileID) |
Defines custom preferences data to be saved into older project file versions. | |
Functions for creating, handling and deleting custom (Add-On specific) preferences, which get stored in the project file. Useful for storing Work Environment settings or some inner states of the Add-On which can be read at the next opening of the project.
This paper give hints on how to save own data into the preferences and the actual project file.
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.
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_Preferences_SetOldVersion 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_Preferences_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.
Please study the source code of the DG Test example to see the suggested way of handling the preferences data.
GSErrCode ACAPI_GetPreferences | ( | Int32 * | version, |
GSSize * | nByte, | ||
void * | data | ||
) |
Returns the stored preferences of the add-on.
version | [out] On return contains the version of the stored preferences, or 0 if no preferences were found. |
nByte | [out] On return contains the size of the stored preferences in bytes, or 0 if no preferences were found. |
data | [in/out] On return contains the stored preferences. This parameter can be nullptr. |
GSErrCode ACAPI_Preferences_Platform | ( | Int32 * | version, |
GSSize * | nByte, | ||
void * | data, | ||
unsigned short * | platformSign | ||
) |
Returns the stored preferences of the add-on.
version | [out] On return contains the version of the stored preferences, or 0 if no preferences were found. |
nByte | [out] On return contains the size of the stored preferences in bytes, or 0 if no preferences were found. |
data | [in/out] On return contains the stored preferences. |
platformSign | [out] On return contains the platform identifier of the stored preferences. |
GSErrCode ACAPI_Preferences_SetOldVersion | ( | Int32 | version, |
GSSize | nByte, | ||
const void * | data, | ||
unsigned short | platformSign, | ||
API_FTypeID | oldPlanFileID | ||
) |
Defines custom preferences data to be saved into older project file versions.
version | [in] The version of the data to be stored. |
nByte | [in] The size of the data to be stored. |
data | [in] The preferences data you would like to store for the specified plan version. |
platformSign | [in] The platform identifier of the data (GS::Win_Platform_Sign, GS::Mac_Platform_Sign, GS::Mactel_Platform_Sign |
oldPlanFileID | [in] The plan file format associated with the preferences data when saving the project into this plan version. The value of this parameter can be: |
GSErrCode ACAPI_SetPreferences | ( | Int32 | version, |
GSSize | nByte, | ||
const void * | data | ||
) |
Saves custom preferences data into the preferences file.
version | [in] The version of the data to be stored. |
nByte | [in] The size of the data to be stored. |
data | [in] The preferences data you would like to store. |