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.
SOLVED!

I want to put the ID value in C++ while creating Beam.

LeeJaeYoung
Virtuoso

LeeJaeYoung_0-1690293520091.png

I want to put the id value in C++ while creating Beam.
What should I do?
I created it by looking at the create element_test code.

What can I study?
I'm a beginner who can understand if you give me the code. ^^

 

1. Solved: Get element's ID - Graphisoft Community

 

 

 

AC27 on window 11
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
ReignBough
Enthusiast

Is this what you need: ACAPI_Database(APIDb_ChangeElementInfoStringID, ...)?

 

~ReignBough~
ARCHICAD 26 INT (from AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS

View solution in original post

9 REPLIES 9
Solution
ReignBough
Enthusiast

Is this what you need: ACAPI_Database(APIDb_ChangeElementInfoStringID, ...)?

 

~ReignBough~
ARCHICAD 26 INT (from AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS
LeeJaeYoung
Virtuoso
GSErrCode ACAPI_Database(APIDb_ChangeElementInfoStringID,element.header.guid, "ABC111");
err = ACAPI_Element_Create(&element, &memo);
if (err != NoError) {
ACAPI_WriteReport("ACAPI_Element_Create (Beam) has failed with error code %ld!", true, err);
}
LeeJaeYoung_0-1690358299678.png

 


 

 

I'm a beginner so I don't understand because I don't have the code.
I need a code that can change the ID value.

1. I'm curious whether it's before or after creation and why the error occurs. ^^

 

 

  

LeeJaeYoung_0-1690359597337.png

1. 

err = ACAPI_Database(APIDb_ChangeElementInfoStringID, &element.header.guid, "xx");
if (err != NoError) {
ACAPI_WriteReport("ACAPI_Element_Create (Beam) has failed with error code %ld!", true, err);
return;
}
 
err = ACAPI_Element_Create(&element, &memo);
if (err != NoError) {
ACAPI_WriteReport("ACAPI_Element_Create (Beam) has failed with error code %ld!", true, err);
}
 
2.  archicad is dead
err = ACAPI_Element_Create(&element, &memo);
if (err != NoError) {
ACAPI_WriteReport("ACAPI_Element_Create (Beam) has failed with error code %ld!", true, err);
}
 
err = ACAPI_Database(APIDb_ChangeElementInfoStringID, &element.header.guid, "xx");
if (err != NoError) {
ACAPI_WriteReport("ACAPI_Element_Create (Beam) has failed with error code %ld!", true, err);
return;
}

 

 

AC27 on window 11
Miha Nahtigal
Advocate

You need to call your routines inside ACAPI_CallUndoableCommand()  block. 

BIMquants.comBETA - Quantities and Costs Estimation in Archicad - BETA testers needed.

 err = ACAPI_CallUndoableCommand("Create Beam",
[&]() -> GSErrCode {
return ACAPI_Database(APIDb_ChangeElementInfoStringID, &element.header.guid, "xx");
});

 

LeeJaeYoung_0-1690381331525.png

The id value did not change to "XX".

 

 

 

 

 err = ACAPI_CallUndoableCommand("Create Beam",
[&]() -> GSErrCode {
return ACAPI_Element_Create(&element, &memo);
});

 

The following error occurs.

AC27 on window 11
LeeJaeYoung
Virtuoso

thank you so much. ^^

I understand now. ^^

AC27 on window 11

err = ACAPI_Database(APIDb_ChangeElementInfoStringID, &element.header.guid, &na);

 

스크린샷 2023-10-06 131651.png

ACAPI_Database not found in archicad 27 api
There is also no content in ACAPinc.h.
What should I study?

 

And I don't have apidevkit.chm, where should I search for it?

AC27 on window 11

Check migration documentation and ACAPI_MigrationHeader.hpp inside Support\Inc folder

 

Use  ACAPI_Element_ChangeElementInfoString() instead of ACAPI_Database(APIDb_ChangeElementInfoStringID...)

BIMquants.comBETA - Quantities and Costs Estimation in Archicad - BETA testers needed.

Thank you for your advice.^^

Have a happy weekend.

AC27 on window 11
ReignBough
Enthusiast

When functions/structures were changed in SDK (and we used them), we put them in a function wrapper to call the proper functions/structure member. Especially, when we support the lower versions of ArchiCAD.

 

Example:

GSErrCode Db_ChangeElementInfoString(API_Guid* guid, GS::UniString* id)
{
if (ARCHICAD_VER >= 27)
return ACAPI_Element_ChangeElementInfoString(guid, id); else if (ARCHICAD_VER < 27 && ARCHICAD_VER >= 23) return ACAPI_Database(APIDb_ChangeElementInfoStringID, guid, id); else //if (ARCHICAD_VER < 23)
return APIERR_NOTSUPPORTED; //return NoError; }

void Elem_SetElemType(API_Elemennt& elem, API_ElemTypeID typeId)
{
if (ARCHICAD_VER >= 26)
elem.header.type.typeID = typeID;
else //if (ARCHICAD_VER < 26)
elem.header.typeId = typeID;
}

 ARCHICAD_VER is then defined in Project Property's Preprocessor.

~ReignBough~
ARCHICAD 26 INT (from AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS