We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2023-07-25 04:06 PM
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
Solved! Go to Solution.
2023-07-26 05:36 AM
Is this what you need: ACAPI_Database(APIDb_ChangeElementInfoStringID, ...)?
2023-07-26 05:36 AM
Is this what you need: ACAPI_Database(APIDb_ChangeElementInfoStringID, ...)?
2023-07-26 09:01 AM - edited 2023-07-26 10:21 AM
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. ^^
1.
2023-07-26 03:30 PM
You need to call your routines inside ACAPI_CallUndoableCommand() block.
2023-07-26 04:11 PM - edited 2023-07-26 04:26 PM
err = ACAPI_CallUndoableCommand("Create Beam",
[&]() -> GSErrCode {
return ACAPI_Database(APIDb_ChangeElementInfoStringID, &element.header.guid, "xx");
});
The id value did not change to "XX".
err = ACAPI_CallUndoableCommand("Create Beam",
[&]() -> GSErrCode {
return ACAPI_Element_Create(&element, &memo);
});
The following error occurs.
2023-07-27 05:54 AM
thank you so much. ^^
I understand now. ^^
2023-10-06 06:12 AM - edited 2023-10-06 06:20 AM
err = ACAPI_Database(APIDb_ChangeElementInfoStringID, &element.header.guid, &na);
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?
2023-10-06 06:46 PM
Check migration documentation and ACAPI_MigrationHeader.hpp inside Support\Inc folder
Use ACAPI_Element_ChangeElementInfoString() instead of ACAPI_Database(APIDb_ChangeElementInfoStringID...)
2023-10-07 03:20 AM
Thank you for your advice.^^
Have a happy weekend.
2023-10-10 08:32 AM
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.