Archicad C++ API
About Archicad add-on development using the C++ API.

What action can trigger API_IAttributeEventHandler

WalterWhite
Contributor

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.

4 REPLIES 4

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...

Ok,I'll go back and try. Thank you very much.

Viktor Kovacs
Graphisoft
Graphisoft

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);

 

Ok, I'll have a try

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!