The Global ARCHICAD Community

Stay informed. Get help. Share your knowledge.

Discussions about using GRAPHISOFT's tools (API DevKit) for independent software developers

Moderators: Karl Ottenstein, LaszloNagy, ejrolon, Barry Kelly, gkmethy, MOREH Tamas, Akos Somorjai, Ed Brown, Mihály Palenik, Tibor Lorántfy, rmasaki

#302805
Hi,

Here's a short code snippet for getting the outside coordinates of walls:
Code: Select all
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)[i].x;
			(*memo.coords)[i].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.
#302826
Tibor Lorántfy wrote:
Wed Oct 16, 2019 1:48 pm
Hi,

Here's a short code snippet for getting the outside coordinates of walls:
Code: Select all
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)[i].x;
			(*memo.coords)[i].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?