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

Suspend Groups in Element Observers / ElementEventHandlerProc

Is it possible to suspend groups in Element Observers / ElementEventHandlerProc?


When I try to use ACAPI_Element_Tool with APITool_SuspendGroups I get  APIERR_REFUSEDCMD.

I use it like this:

 

err = ACAPI_Element_Tool ({}, APITool_SuspendGroups, nullptr);

 

 Other values in the first parameter give the same error.
I've also tried ungrouping and after the operation grouping an element to achieve a similar effect, but the group/ungroup command needs an undo scope.

Both approaches work for me outside of an event handler.

Are there any other workarounds or am I using one of the commands wrong in the EventHandler context?

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

I got an answer from Support a while ago about this and I just remembered to share it here as well.

To summarize:
They also think it's weird too, that the suspending groups doesn't work in the case of changing the zone polygon.
They will look into it but can't promise anything right now since they have a lot of other developments going on.

View solution in original post

4 REPLIES 4
kuvbur
Enthusiast

Why do you need to ungroup elements? Perhaps it is enough to exclude the processing of groups?

if (elemType->elemHead.typeID == API_GroupID) return NoError;

Structural engineer, developer of free addon for sync GDL param and properties

That won't work unfortunately. I want to change an element  with ACAPI_Element_Change but this requires the Element to not be in a group or suspend groups to be off (see APIERR_BADPARS in the link).

I’ve figured out that this actually isn’t the case for all events!

These are the cases I've found:

Action

API_ElementDBEventID

Suspend Groups Works

Change Zone Polygon

APINotifyElement_Edit

False

Move Zone

APINotifyElement_Edit

True

Change Zone Parameter

APINotifyElement_Change

True

 

So maybe it’s a bug when changing the zone shape?

I sent a ticket about it to support.

Solution

I got an answer from Support a while ago about this and I just remembered to share it here as well.

To summarize:
They also think it's weird too, that the suspending groups doesn't work in the case of changing the zone polygon.
They will look into it but can't promise anything right now since they have a lot of other developments going on.