2025-04-17
01:08 PM
- last edited
a month ago
by
Laszlo Nagy
For now, in my Archicad addon, I need to apply override surfaces for these ("Outside Face Surface", "Internal Face Surface" & "Edge Surface") to be linked together with AC API. (they should be same material)
So I have tried to use this code, but I am always get "GSErrCode" of "-2130312307".
ChatGPT said it's read-only access issue, so I have tried the code after saving the project file.
I am already purchased license so there should be no such problem.
Here is my code.
void ApplySameOverrideSurface()
{
GS::Array<API_Guid> elemList;
GSErrCode err = ACAPI_Element_GetElemList(API_ZombieElemID, &elemList, APIFilt_OnVisLayer);
if (err != NoError)
return;
for (const API_Guid& guid : elemList) {
API_Element element;
BNZeroMemory(&element, sizeof(API_Element));
element.header.guid = guid;
if (ACAPI_Element_Get(&element) != NoError)
continue;
int type;
#if AC_VERSION >= 26
type = element.header.type.typeID;
#else
type = element.header.typeID;
#endif
API_AttributeIndex index;
index = CreateAttributeIndex(1);
API_Element mask;
ACAPI_ELEMENT_MASK_CLEAR(mask);
bool pass = type == API_WallID || API_ObjectID;
if (pass == false)
continue;
switch (type)
{
case API_WallID:
//element.wall.composite != CreateAttributeIndex(0) ? index = element.wall.composite : index = element.wall.buildingMaterial;
element.wall.oppMat = element.wall.buildingMaterial;
element.wall.refMat = element.wall.buildingMaterial;
element.wall.sidMat = element.wall.buildingMaterial;
ACAPI_ELEMENT_MASK_SET(mask, API_WallType, oppMat);
ACAPI_ELEMENT_MASK_SET(mask, API_WallType, refMat);
ACAPI_ELEMENT_MASK_SET(mask, API_WallType, sidMat);
break;
case API_ObjectID:
element.object.mat = index;
element.object.useObjMaterials = false;
ACAPI_ELEMENT_MASK_SET(mask, API_ObjectType, mat);
ACAPI_ELEMENT_MASK_SET(mask, API_ObjectType, useObjMaterials);
break;
}
//// Now apply changes
err = ACAPI_Element_Change(&element, &mask, nullptr, 0, true);
if (err != NoError) {
DBPrintf("Failed to override surface for element: %s\n", APIGuidToString(guid).ToCStr().Get());
}
}
}
If anyone knows the reason, please let me know about it asap.
Kind Regards,
Vladica Zivic
Operating system used: Windows
2025-04-17
01:10 PM
- last edited
a month ago
by
Laszlo Nagy
Here are the screenshots.
Kind Regards,
Vladica
2025-04-18 06:04 PM
Don't believe ChatGPT 😀
API ErrorCode:
APIERR_NEEDSUNDOSCOPE |
-2130312307 | 8106038D | The called command should be encapsulated in a ACAPI_CallUndoableCommand scope. |
You need to call the ACAPI_Element_Change in a ACAPI_CallUndoableCommand.
2025-04-18 06:14 PM
Dont belive ChatGPT 😀
API ErrorCide:
APIERR_NEEDSUNDOSCOPE |
-2130312307 | 8106038D | The called command should be encapsulated in a ACAPI_CallUndoableCommand scope. |
Some functions like the ACAPI_Element_Change should be called in a ACAPI_CallUndoableCommand.
2025-04-18 06:42 PM
I tried to reply twice, but the answers were not published. I'll try again.
Error -2130312307 is:
APIERR_NEEDSUNDOSCOPE "The called command should be encapsulated in a ACAPI_CallUndoableCommand scope"
Some functions should be called in a ACAPI_CallUndoableCommand.
See documentation on ACAPI_CallUndoableCommand and examples.
2025-04-19 08:44 PM
@Oleg FYI Auto Spam was hiding the message.
Macbook Pro M1 Max 64GB ram, OS X 10.XX latest
another Moderator