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.

Door - Relation Parameters / Properties

Anonymous
Not applicable
I am looking for the following door informations in a Model:

- Hinge side
- Wall structure (composition)
- Wall thickness
- Room number
- Room name
- from-Room name
- from-Room number/id

I have been looking for the attributes in the params and IFCProperties but I have not found them yet. Is there a way to get this data as attributes directly from the API?

Or is it something that must be done with the API_DoorRelation?

Thanks in advance.
6 REPLIES 6
Regina Judak
Graphisoft Alumni
Graphisoft Alumni
Hi,

With the help of the API_DoorRelation you can obtain the API_Guid of the rooms that are connected to the door, and from the element info of the door you can get the owner wall's API_Guid. From the API_Guids you can get the room (zone) names, number and the wall's composite and thickness. The name of the parameter which describes the hinge side is "ac_openingSide".

For example if you want to know the information of the door you clicked on:
void		ClickedDoorInfo (void)
{
	API_Element			element;
	API_DoorRelation	doorInfo;

	BNZeroMemory (&element, sizeof (API_Element));

	if (!ClickAnElem ("Click a door", API_DoorID, nullptr, &element.header.typeID, &element.header.guid)) {
		WriteReport_Alert ("No door was clicked");
		return;
	}

	GSErrCode err = ACAPI_Element_Get (&element);
	if (err != NoError) {
		ErrorBeep ("ACAPI_Element_Get (door)", err);
		return;
	}

	err = ACAPI_Element_GetRelations (element.header.guid, API_ZombieElemID, &doorInfo);
	if (err != NoError) {
		ErrorBeep ("ACAPI_Element_GetRelations (door, all data)", err);
		return;
	}

	API_Element		wallElement, fromRoomElement, toRoomElement;

	// Get the information about the owner wall -----------------------
	WriteReport ("Owner wall: %s", APIGuidToString (element.door.owner).ToCStr ().Get ());
	wallElement.header.guid = element.door.owner;
	if (ACAPI_Element_Get (&wallElement) == NoError) { 
		WriteReport ("  wall  composite: %d", wallElement.wall.composite);
		WriteReport ("  wall  thickness at the beginning: %f", wallElement.wall.thickness);
		WriteReport ("  wall  thickness at the end: %f", wallElement.wall.thickness1);
	}

	// Get the information about the rooms -----------------------
	WriteReport ("Connected rooms:");
	WriteReport ("  fromRoom: %s", APIGuidToString (doorInfo.fromRoom).ToCStr ().Get ());
	WriteReport ("  toRoom  : %s", APIGuidToString (doorInfo.toRoom).ToCStr ().Get ());

	fromRoomElement.header.guid = doorInfo.fromRoom;
	toRoomElement.header.guid = doorInfo.toRoom;

	if (ACAPI_Element_Get (&fromRoomElement) == NoError) {
		WriteReport ("  fromRoom  name: %s", GS::UniString (fromRoomElement.zone.roomName).ToCStr ().Get ());
		WriteReport ("  fromRoom  number: %s", GS::UniString (fromRoomElement.zone.roomNoStr ).ToCStr ().Get ());
	}

	if (ACAPI_Element_Get (&toRoomElement) == NoError) {
		WriteReport ("  toRoom  name: %s", GS::UniString (toRoomElement.zone.roomName).ToCStr ().Get ());
		WriteReport ("  toRoom  number: %s", GS::UniString (toRoomElement.zone.roomNoStr ).ToCStr ().Get ());
	}

	// Get the value of the ac_openingSide parameter -----------------------
	API_ElementMemo     memo;

	if (ACAPI_Element_GetMemo (element.header.guid, &memo) == NoError) {
		API_AddParType	**params = memo.params;
		Int32	n = BMGetHandleSize ((GSHandle) params) / sizeof (API_AddParType);

		for (int i = 0; i < n; i++) {
			if (CHEqualASCII ((*params).name, "ac_openingSide", CS_CaseInsensitive)) {
				WriteReport ("ac_openingSide: %s", (*params).value.uStr);
				break;
			}
		}

		ACAPI_DisposeElemMemoHdls (&memo);
	}

	return;
}
Regards,
Regina
ReignBough
Enthusiast
The problem with this is when you use 2 or more overlapping zones. That is, you have zone for the unit (like studio, 1br, 2br, etc.) and the sub-unit (like bedroom, kitchen, living room, etc.). Just put these two zones on different layer and hide the one that you don't need when calling your add-on.
~ReignBough~
ARCHICAD 26 INT (from AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS
Anonymous
Not applicable
Hi Regina,

thank you very much. I have now all Informations I need.

Best regards,

M
Anonymous
Not applicable
Hello Regina:

I was hoping to get some clues as to the best approach for getting Door Label/Stamp Attributes with the API.

You had provided very useful information before:
Regina wrote:
Hi,

The name of the parameter which describes the hinge side is "ac_openingSide".

Regards,
Regina
The infos I am trying to get are in the picture (Doorstamp->Settings->Content3->...):
https://drive.google.com/file/d/1CJJ4gqQRDYQHdMMkrW-O3u-rf41lVMNz/view

It is not clear to me wether these informations should be within the door object/libpart or in the stamp/label itself.

My guess is that they are actually stored in the stamp/label settings. I do not know however how to get a handle to this from the door.

Any suggestions would be appreciated.
Akos Somorjai
Graphisoft
Graphisoft
mar_kq wrote:
Hello Regina:

I was hoping to get some clues as to the best approach for getting Door Label/Stamp Attributes with the API.

You had provided very useful information before:
Regina wrote:
Hi,

The name of the parameter which describes the hinge side is "ac_openingSide".

Regards,
Regina
The infos I am trying to get are in the picture (Doorstamp->Settings->Content3->...):
https://drive.google.com/file/d/1CJJ4gqQRDYQHdMMkrW-O3u-rf41lVMNz/view

It is not clear to me wether these informations should be within the door object/libpart or in the stamp/label itself.

My guess is that they are actually stored in the stamp/label settings. I do not know however how to get a handle to this from the door.

Any suggestions would be appreciated.
Hi,

The following code snippet will give you the label(s) connected to a door/window:
	GS::Array<API_Guid> connectedLabels;
	ACAPI_Element_GetConnectedElements (doorGuid, API_LabelID, &connectedLabels);


Best, Akos
Anonymous
Not applicable
Akos wrote:

Hi,

The following code snippet will give you the label(s) connected to a door/window:
	GS::Array<API_Guid> connectedLabels;
	ACAPI_Element_GetConnectedElements (doorGuid, API_LabelID, &connectedLabels);


Best, Akos
Hi Akos,

thanks for the suggestion.

I was able to retrieve the information using the guid of the door stamp directly through ACAPI_Element_GetMemo as suggested here:
archicad-talk.graphisoft.com/viewtopic.php?t=58645&sid=01ca91a39e2d5b62729678c17b88a1c5

But When I try using the ACAPI_Element_GetConnectedElements (with element.header.guid or element.door.head.guid) the resulting Array is empty. Any ideas why I am getting this behaviour?

I am trying this now on AC21 by the way.