Register or unregister your add-on to be notified if some attributes are deleted and replaced by other attributes.
GSErrCode ACAPI_Notify_CatchAttributeReplacement ( APIAttributeReplacementHandlerProc* handlerProc );
Parameters
- handlerProc
- [in] The callback procedure to call when notifications are sent out on replacement of attributes. Specifying
nullptr
here means you don’t need the notifications any more.
Return Values
NoError
- The required operation finished successfully.
For other common API errors see the API Errors document.
Remarks
This function enables the API tool add-on catch the deletion and replacement of the attributes in the project. This operation can be done with the Delete and Replace option in the Attribute Manager dialog.
If you do not need to catch the changes of default settings any longer, please remember to unregister by calling ACAPI_Notify_CatchAttributeReplacement
for the required element type with nullptr
in the handlerProc
parameter.
Example
// ----------------------------------------------------------------------------- // Attribute replacement handler function // ----------------------------------------------------------------------------- GSErrCode __ACENV_CALL HandleAttributeReplacement (const API_AttributeReplaceIndexTable& table) { char msgStr[256]; if (table.ContainsKey (API_AttrTypeID::API_BuildingMaterialID)) { for (const auto& entry : table[API_AttrTypeID::API_BuildingMaterialID]) { sprintf (msgStr, "Changed Material: old index = %d, new index = %d", *entry.key, *entry.value); ACAPI_WriteReport (msgStr, false); } } return NoError; } // HandleAttributeReplacement // ----------------------------------------------------------------------------- // Called after the Add-On has been loaded into memory // ----------------------------------------------------------------------------- GSErrCode __ACENV_CALL Initialize (void) { GSErrCode err = ACAPI_Notify_CatchAttributeReplacement (HandleAttributeReplacement); return err; } // Initialize
Requirements
- Version: API 26 or later
- Header: ACAPinc.h