2025-07-24 06:50 AM
I'm starting to learn the Archicad API and could use some help getting started, as there isn't much documentation available.
Specifically, I'd like to know how to retrieve all the available door types in a project and how to assign a door type to a door.
Thank you!
2025-07-24 06:52 AM
By the way, please show me how to change Door's Marker Type. Thank you!
2025-07-25 09:51 AM
Hi! I agree that the documentation is lacking a bit. I'd suggest to start first with the "Element_Test" example coming with the SDKs. There are some example commands where door elements are accessed. Take a look at that first.
With "changing the type" you mean changing the underlying GDL-object used right? That's quite involved. You'll have to learn to work with Library Parts and then change the associated library part in the door element. Here the "LibPart_Test" example project can give you the first pointers.
To list all available door types you'll need to also iterate through all the loaded libraries and the library parts within. The "LibraryManagement_Test" example project might give you ideas.
2025-07-27 11:58 AM
I don't have LibraryManagement_Test in my examples. Where can I get it?
2025-07-28 09:43 AM
It comes with AC28 DevKits. Previous versions don't have it.
But "LibPart_Test" also includes some handling of loaded libraries. Search for "APIEnv_GetLibrariesID".
2025-07-29 10:26 AM
Thank you, but I still haven't found a way to distinguish the door type from the other types. Can you please show me how to do that in more detail?
2025-07-29 10:31 AM
I found a way to change the door library part:
void __stdcall OnTagType(NativeTypeModel* selectedType)
{
GS::Array<API_Guid> doorGuids;
GSErrCode err = ACAPI_Element_GetElemList(API_DoorID, &doorGuids, APIFilt_OnActFloor);
if (err != NoError) {
ACAPI_WriteReport("Failed to get door elements list.", true);
return;
}
else
{
GS::UniString message = GS::UniString::Printf("Changing %d door elements.", doorGuids.GetSize());
ACAPI_WriteReport(message, false);
}
int finalCount = 0;
for (const API_Guid& doorGuid : doorGuids) {
API_Element element;
API_ElementMemo memo;
GSErrCode err;
API_Element mask;
element.header.guid = doorGuid;
// 2. Get the existing element's data
err = ACAPI_Element_Get(&element);
if (err != NoError) { /* Handle error */ }
err = ACAPI_Element_GetMemo(element.header.guid, &memo, APIMemoMask_All);
if (err != NoError) { /* Handle error */ }
// 3. Update the library index
element.object.libInd = selectedType->id;
// 4. Get default parameters for the new library part
double a, b;
Int32 parCount;
API_AddParType** addPars = nullptr;
err = ACAPI_LibraryPart_GetParams(selectedType->id, &a, &b, &parCount, &addPars);
if (err != NoError) { /* Handle error */ }
// 5. Update memo params
memo.params = addPars;
// 6. Apply changes to the element
ACAPI_ELEMENT_MASK_CLEAR(mask);
ACAPI_ELEMENT_MASK_SET(mask, API_DoorType, openingBase.libInd); // Or other relevant masks
err = ACAPI_Element_Change(&element, &mask, &memo, APIMemoMask_AddPars, true);
if (err != NoError) {
ACAPI_WriteReport(GS::UniString::Printf("Failed to change door element %s. Error: %d",
element.header.guid, err), false);
}
else
{
finalCount++;
}
// 7. Dispose of handles
ACAPI_DisposeElemMemoHdls(&memo);
}
And don't forget to put it in a ACAPI_CallUndoableCommand