We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2019-04-17 06:31 AM - last edited on 2022-10-05 01:25 PM by Daniel Kassai
Solved! Go to Solution.
2019-05-02 03:53 PM
Ralph wrote:There!s no easy way to do that in AC22. In AC23 a new ACAPI_Goodies (APIAny_GetHierarchicalElementOwnerID, ...) will solve this issue.
Erenford wrote:I've just done a few quick tests and confirmed what you've found. Although the note is actually part of the dimension element structure, it appears to present itself independently for selection. And from the API perspective, the guid doesn't refer to an actual element.
Ralph wrote:That's what I thought as well. That's the case for other elems but the text neig has a different guid than the dimension.
The text shown in the dimension shouldn't be a separate element, i.e. the dimension and the text are bound together. So the guid in the API_Neig references the dimension.
I tried a few API calls that lookup linked or connected elements, but nothing produced a result. It's an interesting problem because it could affect at least one of our add-ons (in edge cases). Hopefully there is a call which finds the dimension linked to the note, but someone from GS might need to respond at this point.
2019-04-17 11:01 AM
Erenford wrote:The text shown in the dimension shouldn't be a separate element, i.e. the dimension and the text are bound together. So the guid in the API_Neig references the dimension.
I have the dimension text on marquee, and withACAPI_Selection_GetI can get the API_Neig. I'm trying to obtain the text's parent dimension elem with just the neig, what should I use?
I've triedAPIAny_GetSelectedElementIDbut it just returns the same guid of the API_Neig.
Directly using the guid forACAPI_Element_Getreturns APIERR_BADID.
2019-04-17 02:35 PM
2019-04-23 04:27 AM
Ralph wrote:That's what I thought as well. That's the case for other elems but the text neig has a different guid than the dimension.
The text shown in the dimension shouldn't be a separate element, i.e. the dimension and the text are bound together. So the guid in the API_Neig references the dimension.
void Test6() { API_Neig** selNeigs; API_SelectionInfo selectionInfo; BNZeroMemory(&selectionInfo, sizeof(selectionInfo)); GSErrCode err = ACAPI_Selection_Get(&selectionInfo, &selNeigs, false, true, API_InsidePartially); BMKillHandle((GSHandle*)&selectionInfo.marquee.coords); if (err != NoError) goto Test_Err; API_Element elem; const UInt32 nSel = BMGetHandleSize((GSHandle)selNeigs) / sizeof(API_Neig); WriteReport("nSel = %d", nSel); for (UInt32 ii = 0; ii < nSel && err == NoError; ++ii) { auto& neig = (*selNeigs)[ii]; Write2DebugNeig(neig); // Prints all variables of API_Neig BNZeroMemory(&elem, API_ElementSize); elem.header.guid = neig.guid; err = ACAPI_Element_Get(&elem); if (err != NoError) { WriteReport("[Error] %s - ACAPI_Element_Get()", ErrId2Name(err)); continue; } Write2DebugElem_ElemHead(elem.header); // Prints all variables of API_Elem_Head } Test_Err: BMKillHandle((GSHandle*)&selNeigs); }
2019-04-23 01:53 PM
2019-04-24 05:36 AM
kzaremba wrote:This would work if I already have the Dimension elem at start.
If I understood docs correctly notes and other parts of dimension are stored in memo:
DimensionID - (API_DimElem **) - dimElems Returns the coordinates, the neig information, the text, and the witness line information of the dimensionform memo description
So I would try accessing memo of API_DimensionType and then API_DimElem.
I'm not sure if you are able to access API_Note directly with API_ElementGet. Since it's not API_Element it seems not to have header and GUID?! So as far as I understand taking dimension and then access associated elements would be some way. The other maybe exploding geometry and then a note is converted to txt... but I assume that this is less satisfying since it won't be dimension anymore
2019-04-24 09:06 AM
2019-04-24 01:19 PM
Erenford wrote:I've just done a few quick tests and confirmed what you've found. Although the note is actually part of the dimension element structure, it appears to present itself independently for selection. And from the API perspective, the guid doesn't refer to an actual element.
Ralph wrote:That's what I thought as well. That's the case for other elems but the text neig has a different guid than the dimension.
The text shown in the dimension shouldn't be a separate element, i.e. the dimension and the text are bound together. So the guid in the API_Neig references the dimension.
2019-05-02 03:53 PM
Ralph wrote:There!s no easy way to do that in AC22. In AC23 a new ACAPI_Goodies (APIAny_GetHierarchicalElementOwnerID, ...) will solve this issue.
Erenford wrote:I've just done a few quick tests and confirmed what you've found. Although the note is actually part of the dimension element structure, it appears to present itself independently for selection. And from the API perspective, the guid doesn't refer to an actual element.
Ralph wrote:That's what I thought as well. That's the case for other elems but the text neig has a different guid than the dimension.
The text shown in the dimension shouldn't be a separate element, i.e. the dimension and the text are bound together. So the guid in the API_Neig references the dimension.
I tried a few API calls that lookup linked or connected elements, but nothing produced a result. It's an interesting problem because it could affect at least one of our add-ons (in edge cases). Hopefully there is a call which finds the dimension linked to the note, but someone from GS might need to respond at this point.