We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2023-10-19 06:08 PM - last edited on 2024-09-16 02:29 PM by Doreena Deng
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_CLEAR (mask);
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");
}
Solved! Go to Solution.
2023-10-20 08:28 AM
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: https://graphisoft.github.io/archicad-api-devkit/group___element.html#gaf661e412a0e3a3f6979444c67ec6...
Best,
Bernd
2023-10-20 08:28 AM
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: https://graphisoft.github.io/archicad-api-devkit/group___element.html#gaf661e412a0e3a3f6979444c67ec6...
Best,
Bernd
2023-10-20 08:36 PM
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.
2023-10-20 11:18 PM
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.