Archicad C++ API
About Archicad add-on development using the C++ API.

Issue getting a wall's angle?

cfranklin
Newcomer
I'm having some trouble where I thought I had this understood.

I'm following the examples/documentation for iterating all the elements on the active floor:

        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.

I want to be able to determine the wall's angle and select walls that are non ortho, or angular. (I realize the current code is only checking against 0)

It seems, given the writereports in the code above, that the wall information is indeed being found, and the heights get reported correctly. However, regardless of the wall's angle, this always returns 0 for the angle.

Is there something I'm missing here? How is it possible that I'm able to get the element.wall.height correctly, but the element.wall.angle is not filled in?

Thanks
1 REPLY 1
Ralph Wessel
Mentor
The angle field is the sweep angle for curved walls. It will always be zero for straight walls. If you want the angle from the start point to the end point, you can calculate that using the start coordinate (begC) and end coordinate (endC).
Ralph Wessel BArch