2024-10-10 11:29 AM
I find that the APIdefs_Callback.h file has API_IAttributeEventHandler, and I want to know what action can be triggered.I tried to change the material of the element but it didn't trigger.
2024-10-10 12:09 PM
I think it's triggered when you change the attribute definitions themselves in the Attribute Manager, Attribute Palette or specific Attribute Dialog.
If you want to catch a material change in an element, then you'll need APINotifyElement_Change.
Checkout the Notification_Manager example.
Also here's a related code example: https://graphisoft.github.io/archicad-api-devkit/group___element.html#gad0a9295057964fa5e4a3cfd105bf...
2024-10-10 12:32 PM - edited 2024-10-10 01:49 PM
Ok,I'll go back and try. Thank you very much.
2024-10-10 05:33 PM - edited 2024-10-10 05:33 PM
API_IAttributeEventHandler is called in case of an attribute created, modified, or deleted.
You need to create a class inherited from API_IAttributeEventHandler like this:
class AttributeEventHandler : public API_IAttributeEventHandler
{
public:
virtual void OnCreated (const GS::HashSet<API_Guid>&) const override
{
// do something
}
virtual void OnModified (const GS::HashSet<API_Guid>&) const override
{
// do something
}
virtual void OnDeleted (const GS::HashSet<API_Guid>&) const override
{
// do something
}
};
And you need to register the event handler like this in the Initialize function:
API_Guid eventHandlerId;
ACAPI_Notification_RegisterEventHandler (GS::NewOwned<AttributeEventHandler> (), eventHandlerId);
2024-10-11 12:36 PM - edited 2024-10-11 12:37 PM
Ok, I'll have a try