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.

How do I change the group of an element?

Anonymous
Not applicable
Hi. I'm developing an Archicad add-on that is supposed to automatically change values and coordinates in a plan. At a certain point I have to change data inside a text object which is member of a group. Since the content field can't be changed while the object is in a group, the element must first get out of the group, apply the changes and then get back in. I keep getting the APIERR_BADPARS error from ACAPI_Element_Change function. The code goes like this:

... //element processing

long g=0;
g=elem.header.groupId;

ACAPI_ELEMENT_MASK_CLEAR (mask);
ACAPI_ELEMENT_MASK_SET (mask, API_TextType, head);
elem.text.head.groupId=0;
err = ACAPI_Element_Change (&elem, &mask, NULL, 0, true);

... // text object content change based on ACAPI_Goodies - APIAny_ChangeContentID. This works fine on non-grouped text elements.

ACAPI_ELEMENT_MASK_CLEAR (mask);
ACAPI_ELEMENT_MASK_SET (mask, API_TextType, head);
elem.text.head.groupId=g;
err = ACAPI_Element_Change (&elem, &mask, NULL, 0, true);
The code above lies within an undo session.

I cant' figure out the trick, so .. any help would be apreciated.
1 REPLY 1
Ralph Wessel
Mentor
Marius wrote:
Since the content field can't be changed while the object is in a group, the element must first get out of the group, apply the changes and then get back in.
Marius,

I haven't studied the rest of your code yet, but would it solve your problem if you simply suspended groups (see APITool_SuspendGroups) while you do this?
Ralph Wessel BArch
Software Engineer Speckle Systems