2024-02-11 01:24 AM - last edited on 2024-09-16 02:45 PM by Doreena Deng
Hello Graphisoft Community,
I'm currently developing an ARCHICAD add-on and have come across an issue with calculating the bounding boxes for door labels. While I can obtain the bounding boxes successfully, upon checking the values, I've noticed that some coordinates do not accurately reflect the expected positions — they seem to be represented incorrectly. This issue is particularly puzzling because I can calculate the bounding boxes for zone stamps accurately using a similar method.
Issue Summary: The bounding box data for door labels, specifically some of the coordinates, seem incorrect or not as expected. This contrasts with the results for zone stamps, where the bounding box calculations are accurate and consistent.
Code Snippet:
// Retrieve connected labels for the door
GS::Array<API_Guid> connectedLabels;
if (ACAPI_Grouping_GetConnectedElements(elementGuid, API_LabelID, &connectedLabels) == NoError) {
for (const API_Guid& labelGuid : connectedLabels) {
// Retrieve label element data
API_Element labelElement;
BNZeroMemory(&labelElement, sizeof(API_Element));
labelElement.header.guid = labelGuid;
if (ACAPI_Element_Get(&labelElement) == NoError) {
// Get bounding box for the label
API_Box3D boundingBox;
if (ACAPI_Element_CalcBounds(&labelElement.header, &boundingBox) == NoError) {
// Capturing door label info within the existing label processing loop
DoorLabelInfo info = { APIGuidToString(labelGuid).ToCStr().Get(), boundingBox };
doorLabelInfos.push_back(info);
// Append label GUID and bounding box to the door report
sprintf(reportStr + strlen(reportStr), ", Label GUID: %s, Label Bounding Box: [(%.2f, %.2f, %.2f), (%.2f, %.2f, %.2f)]",
APIGuidToString(labelGuid).ToCStr().Get(),
boundingBox.xMin, boundingBox.yMin, boundingBox.zMin,
boundingBox.xMax, boundingBox.yMax, boundingBox.zMax);
}
else {
// Handle error in retrieving the bounding box
sprintf(reportStr + strlen(reportStr), ", Label GUID: %s, Bounding Box: Not available",
APIGuidToString(labelGuid).ToCStr().Get());
}
}
}
}
Although I successfully obtained bounding boxes for door labels, when I checked the coordinates, some seemed to be represented wrongly.
I have attached a sample project file that I am working on, which illustrates the issue.
I would greatly appreciate any advice, insights, or guidance on resolving this issue. Thank you in advance for your help!