cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

The 2025 Technology Preview Program is now live. Join today!

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

Get/set door types

LeanArc
Contributor

I'm starting to learn the Archicad API and could use some help getting started, as there isn't much documentation available. 

 

Specifically, I'd like to know how to retrieve all the available door types in a project and how to assign a door type to a door.

 

Thank you!

6 REPLIES 6
LeanArc
Contributor

By the way, please show me how to change Door's Marker Type. Thank you!

Hi! I agree that the documentation is lacking a bit. I'd suggest to start first with the "Element_Test" example coming with the SDKs. There are some example commands where door elements are accessed. Take a look at that first.

With "changing the type" you mean changing the underlying GDL-object used right? That's quite involved. You'll have to learn to work with Library Parts and then change the associated library part in the door element. Here the "LibPart_Test" example project can give you the first pointers.

 

To list all available door types you'll need to also iterate through all the loaded libraries and the library parts within. The "LibraryManagement_Test" example project might give you ideas.

Automating Archicad with Add-Ons, GDL-Objects & Python Archi-XT.com

I don't have LibraryManagement_Test in my examples. Where can I get it?

It comes with AC28 DevKits. Previous versions don't have it.
But "LibPart_Test" also includes some handling of loaded libraries. Search for "APIEnv_GetLibrariesID".

Automating Archicad with Add-Ons, GDL-Objects & Python Archi-XT.com

Thank you, but I still haven't found a way to distinguish the door type from the other types. Can you please show me how to do that in more detail?

LeanArc
Contributor

I found a way to change the door library part:

 

void __stdcall OnTagType(NativeTypeModel* selectedType)
{
	GS::Array<API_Guid> doorGuids;

	GSErrCode err = ACAPI_Element_GetElemList(API_DoorID, &doorGuids, APIFilt_OnActFloor);
	if (err != NoError) {
		ACAPI_WriteReport("Failed to get door elements list.", true);
		return;
	}
	else
	{
		GS::UniString message = GS::UniString::Printf("Changing %d door elements.", doorGuids.GetSize());
		ACAPI_WriteReport(message, false);
	}

	int finalCount = 0;

	for (const API_Guid& doorGuid : doorGuids) {
		API_Element element;
		API_ElementMemo   memo;
		GSErrCode         err;
		API_Element       mask;

		element.header.guid = doorGuid;
		// 2. Get the existing element's data
		err = ACAPI_Element_Get(&element);
		if (err != NoError) { /* Handle error */ }
		err = ACAPI_Element_GetMemo(element.header.guid, &memo, APIMemoMask_All);
		if (err != NoError) { /* Handle error */ }

		// 3. Update the library index
		element.object.libInd = selectedType->id;

		// 4. Get default parameters for the new library part
		double a, b;
		Int32 parCount;
		API_AddParType** addPars = nullptr;
		err = ACAPI_LibraryPart_GetParams(selectedType->id, &a, &b, &parCount, &addPars);
		if (err != NoError) { /* Handle error */ }

		// 5. Update memo params
		memo.params = addPars;

		// 6. Apply changes to the element
		ACAPI_ELEMENT_MASK_CLEAR(mask);
		ACAPI_ELEMENT_MASK_SET(mask, API_DoorType, openingBase.libInd); // Or other relevant masks
		err = ACAPI_Element_Change(&element, &mask, &memo, APIMemoMask_AddPars, true);
		if (err != NoError) {
			ACAPI_WriteReport(GS::UniString::Printf("Failed to change door element %s. Error: %d",
				element.header.guid, err), false);
		}
		else
		{
			finalCount++;
		}

		// 7. Dispose of handles
		ACAPI_DisposeElemMemoHdls(&memo);
	}

 And don't forget to put it in a ACAPI_CallUndoableCommand

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!