We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

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

ACAPI_Element_CatchNewElement does not work with specified Type

stahL
Contributor

Hello,

I have a problem with the CatchNewElement Handler

This is my code:

 

 

API_ToolBoxItem elemType = {}; 
elemType.type.typeID = API_ObjectID; 
ACAPI_Element_CatchNewElement(&elemType, ElementEventHandler); 

// Other variants i tried: 

// API_ToolBoxItem elemType_Wall = { API_ObjectID, 0, 0 }; seen here: https://graphisoft.github.io/archicad-api-devkit/group___element.html#ga141f01f381503b52a3cf7af291390df0 

// nullptr -> this works, but i want to only get notified about new objects

 

 

When i use this code and set a breakpoint at the beginning of the ElementEventHandler, it doesnt get triggered.
With nullptr instead of elemType it gets triggered (3x: 1. APINotifyElement_BeginEvents, 2. APINotifyElement_New, 3. APINotifyElement_EndEvents)

Can someone help me with this?

Looking forward to your responses.
Jonas

3 REPLIES 3
kolioi
Booster

I think you have to set the type subcategory. Try this (not tested)

API_ToolBoxItem elemType = {};
elemType.type.typeID = API_ObjectID;
elemType.type.variationID = APIVarId_Object;
ACAPI_Element_CatchNewElement(&elemType, ElementEventHandler);

I tried this as well an it didn't work.

But thank you for the suggestion!

 

Yohei Sekiguchi
Contributor

With nullptr instead of elemType it gets triggered (3x: 1. APINotifyElement_BeginEvents, 2. APINotifyElement_New, 3. APINotifyElement_EndEvents)


You already got the answer. You will always get 'APINotifyElement_BeginEvents' first and 'APINotifyElement_EndEvents' last for element event handlers.