We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2024-04-09 06:04 PM - last edited on 2024-09-17 11:02 AM by Doreena Deng
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
2024-04-10 08:16 AM
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);
2024-04-10 09:00 AM
I tried this as well an it didn't work.
But thank you for the suggestion!
2024-06-28 08:19 AM
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.