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

How to get List of Wall guid that relate to selected zone?

Anonymous
Not applicable
How to get Wall Guid that relate to selected zone?

In my project, I can get zone quantity and wall part out of it. But , are there any method that I can get guid of the wall around selected zone.

This is my code snippet zone function. It's can get the area, volume, of the zone, etc. Another code it's can get "WallPart" from the zone. But It's not "Wall Guid". I want wall Guid because I want to get another value from the wall.

Is it possible?

static void DumpZoneQuantity(API_Element *element)		
{

	API_QuantityPar params;
	API_ZoneAllQuantity zone;
	
	BNZeroMemory(&params,sizeof(API_QuantityPar));
	BNZeroMemory(&zone,sizeof(API_ZoneAllQuantity));

	ACAPI_Element_GetQuantities(API_ZoneID,element->header.index,&params, &zone, NULL, NULL, NULL, NULL, NULL);

	char	s[256] = { '\0' };
	char	output_string[1000] = "";
	sprintf (s, "Room %d \nGuid is %s\n",element->header.index,APIGuid2GSGuid(element->header.guid).ToUniString().ToCStr());
	strcat(output_string,s);
	sprintf (s, "The Height of room is %lf\n",zone.height);
	strcat(output_string,s);
	sprintf (s, "The Area is %lf\n",zone.area);
	strcat(output_string,s);
	sprintf (s, "Volume is %lf\n",zone.volume);
	strcat(output_string,s);
	sprintf (s, "Surface of Wall inside the room (not include windows, holes and doors is %lf\n",zone.wallsSurf);
	strcat(output_string,s);
	sprintf (s, "Surface of doors is %lf and total width of the doors is %lf\n",zone.doorsSurf,zone.doorsWidth);
	strcat(output_string,s);
	sprintf (s, "Surface of window is %lf and total width of window is %lf\n",zone.windowsSurf,zone.windowsWidth);
	strcat(output_string,s);
	WriteReport(output_string);
}

static void Do_SelectedGetValue()
{
	API_SelectionInfo 	selectionInfo;
	API_Neig			**selNeigs = NULL;
	ACAPI_Selection_Get (&selectionInfo, &selNeigs, false);

	if(selectionInfo.typeID == API_SelEmpty)			//No selection so we loop through all zone in the floorplan
	{
		GS::Array<API_Guid> elemList;
		ACAPI_Element_GetElemList (API_ZoneID, &elemList);
		for (Int32 i = 0; i < (Int32)elemList.GetSize (); ++i) {
			API_Element element;
			BNZeroMemory (&element, sizeof (API_Element));
			element.header.guid = elemList;
			if (ACAPI_Element_Get (&element) == NoError) {
				DumpZoneQuantity(&element);
			}
		}
	}
	else											//If we have selection so we look at the zone, if no zone then print error
	{
		Int32 zone_count = 0;
		for (Int32 i = 0; i < selectionInfo.sel_nElem; i++)				//Loop through selection
		{
			API_ElemTypeID		typeID;
			typeID = Neig_To_ElemID ((*selNeigs).neigID);
			if (typeID == API_ZoneID)	
			{
				zone_count++;
				API_Element element;
				BNZeroMemory(&element,sizeof(API_Element));
				element.header.guid = (*selNeigs).guid;
				ACAPI_Element_Get (&element);

				DumpZoneQuantity(&element);
			}
		}

		if(zone_count == 0)
		{
			WriteReport("No zone selected");
		}
	}
}
Code2 : WallPart from RoomRelation. This is the method that I use.

	API_RoomRelation relData;
	ACAPI_Element_GetRelations ((*selNeigs)[0].guid,API_ZombieElemID,(void*) &relData);
	
	API_WallPart *part;		
	part = *(relData.wallPart);
	//To use part[0],part[1] , ... , part[relData.nWallPart-1]
Note : ((*selNeigs)[0] is the zone that I selected it.

In the schedule in Archicad, It can do. I want all value like in the schedule
(picture in next post)

Thank you for your information.


ArchiCAD_Zone_Problem1.jpg

5 REPLIES 5
Anonymous
Not applicable
List and Schedule it can do.

But I cannot code it with API

How do I do?
Ralph Wessel
Mentor
Paodekcal wrote:
Another code it's can get "WallPart" from the zone. But It's not "Wall Guid". I want wall Guid because I want to get another value from the wall.
API_WallPart contains the index of the wall element. You can obtain more information about the wall (including the guid) with ACAPI_Element_Get (using the index and element type).
Ralph Wessel BArch
Anonymous
Not applicable
WOW!!! It's really "a strand of hair hiding a mountain" problem.

Thank you for your advice.

Now I can get Wall guid from index of wall in WallPart.

---------------------------------------------------------------------------

But another question

Can you tell me how API locate "roomedge" polygon index.

Where is the first roomedge of the zone? In the right of the zone. Or start on the left. Clockwise or Counter-Clockwise.
Ralph Wessel
Mentor
Paodekcal wrote:
Can you tell me how API locate "roomedge" polygon index. Where is the first roomedge of the zone? In the right of the zone. Or start on the left. Clockwise or Counter-Clockwise.
The polygon describing the room perimeter is stored in a API_ElementMemo structure associated with the room. You can retrieve this data using ACAPI_Element_GetMemo. Read the documentation on API_Polygon for a better understanding of the memo contents. You can then index into the polygon vertices using roomEdge. Note that you need to examine both the coords and parcs structures in case the edge is an arc.
Ralph Wessel BArch
Anonymous
Not applicable
Thank you very much to you . My work now is more easier.