2019-07-18
10:46 PM
- last edited on
2022-10-05
01:24 PM
by
Daniel Kassai
GS::Array<API_Guid> elemList;
err = ACAPI_Element_GetElemList(API_WallID, &elemList, APIFilt_OnActFloor);
//get all elements of a type id on active floor
API_Neig** selNeigs = (API_Neig * *)BMAllocateHandle(sizeof(API_Neig) * elemList.GetSize(), ALLOCATE_CLEAR, 0);
int selCount = 0;//Added counter to keep track of exact number of elements afterwards.
for (GS::Array<API_Guid>::ConstIterator it = elemList.Enumerate(); it != nullptr; ++it) {
//This is how the Archicad api documentation says to iterate all elements of a type
API_Element element;
BNZeroMemory(&element, sizeof(element));
element.header.guid = *it;
//element.header.typeID = API_WallID;
if (ACAPI_Element_Get(&element) == NoError)
{
float rad2deg = 57.2958f;
ACAPI_WriteReport("wall angle is: %f", false, element.wall.angle * rad2deg);
ACAPI_WriteReport("wall info: %f", false, element.wall.height);
if (element.wall.angle == 0)
{
continue; //skip correct walls
}
(*selNeigs)[selCount].guid = element.header.guid;
++selCount;
}
}
selNeigs = (API_Neig * *)BMReallocHandle((GSHandle)selNeigs, selCount * sizeof(API_Neig), 0, 0);
err = ACAPI_Element_Select(selNeigs, selCount, true);
BMKillHandle(reinterpret_cast<GSHandle*> (&selNeigs));
In the code above I'm just iterating all walls and using that collection to add walls to the current selection. 2019-07-19 02:40 PM