BIM Coordinator Program (INT) April 22, 2024
Find the next step in your career as a Graphisoft Certified BIM Coordinator!
Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

ArchiCAD Add-On: Incorrectly Reporting Embedded Doors in Walls

sercet65
Booster

Hello fellow ArchiCAD developers,

 

I'm currently developing an add-on for ArchiCAD and have encountered an issue that I'm struggling to resolve. The add-on's purpose is to process building elements, specifically to report the properties of walls, including any embedded doors. However, I'm facing a problem where the add-on is incorrectly reporting multiple embedded doors for a single wall, even when there's only one door embedded.

Here's a brief overview of what the add-on does:

  • It iterates through building elements (walls, slabs, zones, doors, and dimensions).
  • For each wall element, it's supposed to identify and report any embedded doors.
  • The output should list each wall with its GUID and the GUIDs of any embedded doors.

Issue:

  • The add-on is listing multiple door GUIDs for single walls, including GUIDs that don't correspond to actual doors in the project.
  • I've used the ACAPI_Element_GetMemo function to retrieve the wallDoors array from the API_ElementMemo struct, but the output contains extraneous data.

 

// Handling Wall elements
if (elemType == API_WallID) {
    API_ElementMemo memo;
    BNZeroMemory(&memo, sizeof(API_ElementMemo));

    if (ACAPI_Element_GetMemo(elementGuid, &memo) == NoError) {
        std::string doorsStr;
        if (memo.wallDoors != nullptr) {
            for (int i = 0; memo.wallDoors[i] != APINULLGuid; ++i) {
                if (!doorsStr.empty()) doorsStr += ", ";
                doorsStr += APIGuidToString(memo.wallDoors[i]).ToCStr().Get();
            }
        }
        if (!doorsStr.empty()) {
            sprintf(reportStr + strlen(reportStr), " Embedded Doors: [%s]", doorsStr.c_str());
        }
    }
    ACAPI_DisposeElemMemoHdls(&memo);
}​

 

 

Any advice, insights, or suggestions on how to properly extract and report only the actual embedded doors for each wall would be greatly appreciated.

This is how my output looks like.

sercet65_0-1703032033188.png

 

Best regards,

1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Viktor Kovacs
Graphisoft
Graphisoft

Use this code to get the correct number of guids in a memo array:

GSSize doorCount = BMGetPtrSize (reinterpret_cast<GSPtr> (memo->wallDoors)) / sizeof (API_Guid);
for (GSSize i = 0; i < doorCount; i++) {
    const API_Guid& doorGuid = memo->wallDoors[i];
    // do something with the door
}

 

View solution in original post

2 REPLIES 2
Solution
Viktor Kovacs
Graphisoft
Graphisoft

Use this code to get the correct number of guids in a memo array:

GSSize doorCount = BMGetPtrSize (reinterpret_cast<GSPtr> (memo->wallDoors)) / sizeof (API_Guid);
for (GSSize i = 0; i < doorCount; i++) {
    const API_Guid& doorGuid = memo->wallDoors[i];
    // do something with the door
}

 

sercet65
Booster

@Viktor Kovacs Thank you very much for the feedback. That was very helpful.

Learn and get certified!

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!