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

Changing elements


Hello! I've been struggling to make things work here.

The code builds, the command runs without trouble and I get the dialog at the end. But I get no changes to my element. can't figure out what's still missing. I've used most of the code from the examples.

I'm not using 'ACAPI_Element_Edit', cause I warns that: 

No matching function for call to 'ACAPI_Element_Edit'


#include "basicgeometry.h"



void EditWall ()
    API_Element            element, mask;
    API_ElementMemo        memo;
//    GSErrCode err = NoError;
    element = {};
    memo = {};
    ACAPI_Element_Get (&element);
    ACAPI_Element_GetMemo (element.header.guid, &memo);
    ACAPI_ELEMENT_MASK_SET (mask, API_WallType, thickness);
    element.wall.thickness = 1.0;
//    ACAPI_Element_Edit(&element, &mask);

    ACAPI_Element_Change (&element, &mask, &memo, 0, true);
    DG::InformationAlert ("Exit", "Click ok to continue", "OK");




Archicad User Since 2013
GDL Developer
Experimenting with API
from Brazil

Hi Vítor,

The element.header.guid is empty since you didn't assign anything.
So both ACAPI_Element_Get and ACAPI_Element_GetMemo won't know which element to look for.
You'll have to get a guid of a wall first.


There are a lot of possibilities for this.

E.g. iterate through all walls with ACAPI_Element_GetElemList or get the guid from a selection with ACAPI_Selection_Get

There's a good code example for it on the linked documentation page.


The rest of your code seems fine for changing the wall thickness.

If you want to use ACAPI_Element_Edit you will have to pass different arguments as documented here:


Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website:

It finally worked!
Another very important detail that was missing, from the beginning, was that it needs a ACAPI_CallUndoableCommand before everything, followed by a ACAPI_DisposeElemMemoHdls as it seems. Found many occurrences of this issue in the forum. I guess that should be more explicit within the first steps.

Archicad User Since 2013
GDL Developer
Experimenting with API
from Brazil

Another point -- for cleaner code: API_ElementMemo  is not required and should be replaced with nullptr. It's only required if your going to replace some of the attributes in the Memo structure.


Windows 11 - Visual Studio 2022; ArchiCAD 27

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!