Archicad 28 C++ API
|
Functions for creating, handling and deleting custom (Add-On specific) Modul Data. Differs from User Data in not being attached to specific elements or element groups. This is a legacy technology, please use Add-On Objects instead. More...
Classes | |
struct | API_ModulData |
Control information of a custom data section saved into the project file. More... | |
Enumerations | |
enum | API_MDSetCmd { APIMDSetMerge_TW = 11 , APIMDSetMerge_HLM = 12 , APIMDSetMerge_Merge = 13 } |
ModulData operation code. More... | |
Functions | |
GSErrCode | ACAPI_ModulData_Store (const API_ModulData *info, const GS::UniString &modulName=GS::EmptyUniString) |
Saves a custom data section into the project database. | |
GSErrCode | ACAPI_ModulData_GetInfo (API_ModulData *info, const GS::UniString &modulName=GS::EmptyUniString) |
Returns information on the custom data section stored in the project database. | |
GSErrCode | ACAPI_ModulData_Get (API_ModulData *info, const GS::UniString &modulName=GS::EmptyUniString) |
Returns the data section stored in the project database. | |
GSErrCode | ACAPI_ModulData_GetList (GS::Array< GS::UniString > *modulNameList) |
Returns a list of names of the custom data sections stored in the project database. | |
GSErrCode | ACAPI_ModulData_Delete (const GS::UniString &modulName=GS::EmptyUniString) |
Removes the custom data section stored in the project database. | |
Functions for creating, handling and deleting custom (Add-On specific) Modul Data. Differs from User Data in not being attached to specific elements or element groups. This is a legacy technology, please use Add-On Objects instead.
It allows each add-on to own custom data sections in Archicad project files. No limitation is imposed on the structure or content, not even on the amount of saved bytes. Archicad knows nothing about its internal format, it just preserves a number of bytes in the project file and returns them upon requests.
Data sections are identified uniquely by the add-on's modul ID ('MDID') and an optional modul name string. This means the one data per add-on limitation of previous versions has been dissolved.
All of the ModulData Manager functions begin with the ACAPI_ModulData_ prefix. They are as follows:
Refer to the ModulData Manager example project to see detailed examples on using these functions.
In certain situations modules of the same add-on can conflict with each other. When merging another plan into the project, it might be necessary to keep both the original and the incoming modul data, and to combine them together. Since the host application does not know the content of the modules, the owner add-on is requested to resolve the conflict.
For this purpose the add-on needs to implement an APIModulDataMergeHandlerProc callback handler function, and pass the function pointer to Archicad with the ACAPI_AddOnIntegration_InstallModulDataMergeHandler in the Initialize routine. It is also necessary to inform Archicad that the add-on is prepared for merging module data: this can be done with the ACAPI_AddOnIntegration_RegisterModulDataHandler function called from RegisterInterface.
In Teamwork mode it is also possible that the same module data is modified by the owner and by other team members. In this case the local and the server version of the data is conflicting at synchronization, and the add-on's APIModulDataMergeHandlerProc is called to adjust the proper data.
When Archicad calls the handler function, the API_MDSetCmd moduldata event codes inform you about the type of the actual operation:
Event Code | Description |
---|---|
APIMDSetMerge_TW | The data sections should be merged because of a Teamwork operation (e.g. Receive changes). |
APIMDSetMerge_HLM | The data section from a Hotlinked module should be merged into the main database. |
APIMDSetMerge_Merge | The data section should be merged from a file which was merged into the main project, or from a paste or Drag&Drop operation. |
The API_ModulData
structure contains a version number. If your data structure has to be changed, increase the version number. Upon retrieving the data section, check the version information and provide backward compatibility if possible.
Refer to the API_ModulData structure for more details.
Since Archicad is a multi-platform application, all data written into the project file should be readable on the opposite platform too. As byte ordering is different on the Windows and on the Macintosh, for the correct interpretation the add-on needs to know on which platform the data was created. If the platform code differs from the actual platform, perform the necessary byte swapping operations using the GSRoot module, or use Memory Channel to read and write the custom data.
Refer to the API_ModulData structure for more details.
Saving data into old format project
If the structure of the custom data has changed since the previous version, you need to implement an APIModulDataSaveOldFormatHandlerProc callback function to be able to convert your modules when saving into an older format project. In order to be called this handler, the function pointer must be passed with ACAPI_AddOnIntegration_InstallModulDataSaveOldFormatHandler, and the modul data handling feature must be registered with ACAPI_AddOnIntegration_RegisterModulDataHandler.
When Archicad calls this function, the add-on should create the converted data according to the given plan file format, and pass it back to the application. The old format data should not be stored with ACAPI_ModulData_Store, nor the current data needs to be deleted or modified during the project save operation.
If the add-on does not install this converter callback routine, the available current format module data is saved into the old version project as well.
Notice that it is not recommended to store unique ID-type references to Archicad elements in the module data; for this purpose try to use the Element Set Manager service instead.
Every add-on can save custom data into an Archicad single project, teamwork project, or hotlink module. This lets the add-on programmers have a custom - unlimited length - data section in the project. The benefit of this feature is that it spares the Archicad users from having to care about many separate files that belong to a project and are needed by add-ons, when the project file changes its location (by copy, paste, email, ftp, etc).
The custom section of the project file can be anything the add-on programmer desires to save for his/her add-on, but special attention is needed for the issues of maintaining this data when the add-on is active, and also, the correct byte order, if the add-on was developed for multiplatform usage.
Trick: You can delete add-on data from a project file following these steps:
APIData
subfolder.At the next opening of the project, your add-on data will not be present. This way you can decrease the load time of Archicad, test the initialization of an add-on with no add-on data present, or get rid of add-on data for add-ons you don't use any more.
Warning: The data deleted following this method will be lost and cannot be recovered!
enum API_MDSetCmd |
ModulData operation code.
APIMDSetMerge_Merge
code means that the notification is posted because of the database must be updated; invoked by the Merge or Copy commands. The APIMDSetMerge_HLM and APIMDSetMerge_TW means the notification is posted because of the databases must be merged; invoked by Teamwork (Send Changes, Receive Changes), or Place Hotlink Module commands, respectively. GSErrCode ACAPI_ModulData_Delete | ( | const GS::UniString & | modulName = GS::EmptyUniString | ) |
Removes the custom data section stored in the project database.
modulName | [in] Identifier name of the modul data (optional). |
GSErrCode ACAPI_ModulData_Get | ( | API_ModulData * | info, |
const GS::UniString & | modulName = GS::EmptyUniString |
||
) |
Returns the data section stored in the project database.
info | [out] Contains the the custom data stored in the project file on return. |
modulName | [in] Identifier name of the modul data (optional). |
GSErrCode ACAPI_ModulData_GetInfo | ( | API_ModulData * | info, |
const GS::UniString & | modulName = GS::EmptyUniString |
||
) |
Returns information on the custom data section stored in the project database.
info | [out] The version and platform information of the stored moduldata. |
modulName | [in] Identifier name of the modul data (optional). |
GSErrCode ACAPI_ModulData_GetList | ( | GS::Array< GS::UniString > * | modulNameList | ) |
Returns a list of names of the custom data sections stored in the project database.
modulNameList | [out] List of moduldata names stored by the add-on into the current project. |
GSErrCode ACAPI_ModulData_Store | ( | const API_ModulData * | info, |
const GS::UniString & | modulName = GS::EmptyUniString |
||
) |
Saves a custom data section into the project database.
info | [in] The module data to store. It also includes platform and version information. |
modulName | [in] Identifier name of the modul data (optional). |