2023-12-21
12:19 AM
- last edited
2 weeks ago
by
Laszlo Nagy
Hello fellow developers,
I'm currently working on an Archicad Add-On where I need to extract detailed information about dimension elements. My current implementation allows me to retrieve basic information such as the GUID, line pen, and text position of dimension elements. Here is a snippet of my code for context:
void ReportDimensionElementProperties(const API_Guid& elementGuid, API_ElemTypeID elemType, std::ofstream& outFile) {
char reportStr[1024];
API_Element element;
BNZeroMemory(&element, sizeof(API_Element));
element.header.guid = elementGuid;
GSErrCode err = ACAPI_Element_Get(&element);
if (err == NoError && elemType == API_DimensionID) {
API_DimensionType& dimension = element.dimension;
// Format the report string with extracted properties from linear dimension
sprintf(reportStr, "Linear Dimension, GUID: %s, Line Pen: %d, Text Position: %d",
APIGuidToString(elementGuid).ToCStr().Get(),
dimension.linPen,
dimension.textPos);
outFile << reportStr << std::endl;
}
else {
// Handle error in retrieving the element or unsupported element type
}
}
However, I would like to delve deeper and retrieve more information such as:
I've explored the Archicad API documentation but haven't found a clear path to achieve this. Does anyone have experience or suggestions on how to extract these additional details for dimension elements? Any insights or guidance would be greatly appreciated, especially code snippets or references to specific API functions that could be useful.
Thank you in advance!
2 weeks ago
Hello, any solutions? Maybe u've already found any?
2 weeks ago
I think, you can get more info using ACAPI_Element_GetMemo
The dimElems field contains handle of API_DimElem structures.
2 weeks ago
Hi,
Oleg is right, the API_DimElem array contains most of the detailed information you are looking for. You can get it with `ACAPI_Element_GetMemo()`.
Specifically:
1. dimElem.note.contentUStr contains the dimension text as a `GS::UniString*`.
2. The GUIDs of these texts can only be obtained by iterating over `API_TextID` type elements, and checking their `owner` fields
3. dimElem.base.base.type and dimElem.base.base.guid identifies the dimensioned elements
Best, Akos