We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

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

How can I get the coordinates of a wall?

Anonymous
Not applicable
Hi,
How can I get the center and the outside coordinates of the wall?
In API,I can only the center or the outside coordinates?How can I get both?
2 REPLIES 2
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
Hi,

Here's a short code snippet for getting the outside coordinates of walls:
GS::Array<API_Guid> wallGuids;
ACAPI_Element_GetElemList (API_WallID, &wallGuids);
for (UIndex ii = 0; ii < wallGuids.GetSize (); ++ii) {
	API_Element element = {};
	element.header.guid = wallGuids[ii];
	GSErrCode err = ACAPI_Element_Get (&element);
	if (err != NoError)
		continue;

	const API_WallType& wall = element.wall;

	wall.begC;	// start coordinate of the wall reference line
	wall.endC;	// end coordinate of the wall reference line

	API_ElementMemo memo = {};
	err = ACAPI_Element_GetMemo (wall.head.guid, &memo);
	if (err != NoError)
		continue;

	if (memo.coords) {
		// (*memo.coords) array contains the outside coordinates
		for (Int32 i = 1; i <= wall.poly.nCoords; i++) {
			(*memo.coords).x;
			(*memo.coords).y;
		}
	}

	ACAPI_DisposeElemMemoHdls (&memo);
}
What do you mean by the center coordinate of the wall?
Do you mean the center of the reference line of the wall? In that case you can simply calculate it from the wall.begC and wall.endC, since those are the start and the end coordinates of the wall reference line.
Anonymous
Not applicable
Tibor wrote:
Hi,

Here's a short code snippet for getting the outside coordinates of walls:
GS::Array<API_Guid> wallGuids;
ACAPI_Element_GetElemList (API_WallID, &wallGuids);
for (UIndex ii = 0; ii < wallGuids.GetSize (); ++ii) {
	API_Element element = {};
	element.header.guid = wallGuids[ii];
	GSErrCode err = ACAPI_Element_Get (&element);
	if (err != NoError)
		continue;

	const API_WallType& wall = element.wall;

	wall.begC;	// start coordinate of the wall reference line
	wall.endC;	// end coordinate of the wall reference line

	API_ElementMemo memo = {};
	err = ACAPI_Element_GetMemo (wall.head.guid, &memo);
	if (err != NoError)
		continue;

	if (memo.coords) {
		// (*memo.coords) array contains the outside coordinates
		for (Int32 i = 1; i <= wall.poly.nCoords; i++) {
			(*memo.coords).x;
			(*memo.coords).y;
		}
	}

	ACAPI_DisposeElemMemoHdls (&memo);
}
What do you mean by the center coordinate of the wall?
Do you mean the center of the reference line of the wall? In that case you can simply calculate it from the wall.begC and wall.endC, since those are the start and the end coordinates of the wall reference line.
Thanks.
wall.begC and wall.endC are the start and the end coordinates of the wall reference line.
But If I set the referenceLineLocation of the wall is APIWallRefLine_CoreOutside, are wall.begC and wall.endC also the center coordinates of the reference line of the wall?