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

Using Do_SolidOperation_Create from Element_Test development kit.

roni
Booster

Hi Team,
I was trying out to create a opening in a wall in ArchiCAD. From the ArchiCAD UI I can create polygonal shaped openings, but it was not supported via C++ library functions (yet to expose).
Checking other possibilities, I found a way to do using Solid Element Operations, where I merge a Morph (Operator) into Wall(Target) and do Subtract operation which will create an opening. This can be done in ArchiCAD UI.
Now trying to automate using C++ code, we have a function named Do_SolidOperation_Create in Element_Test addon provided in development kit. Added the code below

 

void Do_SolidOperation_Create (void)
{
	API_ElemTypeID		typeID;
	API_Guid			guid_Target, guid_Operator, guid_Operator2;
	GS::Array<API_Guid>	guid_Results;

	if (!ClickAnElem ("Click on a solid operation target", API_MorphID, nullptr, &typeID, &guid_Target)) {
		WriteReport_Alert ("No element was clicked.");
		return;
	}

	if (!ClickAnElem ("Click on a solid operator element", API_MorphID, nullptr, &typeID, &guid_Operator)) {
		WriteReport_Alert ("No element was clicked.");
		return;
	}

	if (!ClickAnElem ("Click on a solid operator element", API_MorphID, nullptr, &typeID, &guid_Operator2)) {
		WriteReport_Alert ("No element was clicked.");
		return;
	}

	GSErrCode err = ACAPI_Element_SolidOperation_Create (guid_Target, guid_Operator, APISolid_Substract, &guid_Results);
	if (err != NoError) {
		if (err == APIERR_NO3D)
			WriteReport_Alert ("Solid operation targets and operators can be freeshape elements only.");
		else
			WriteReport_Alert ("ACAPI_Element_SolidOperation_Create failed: %d", err);
	} else {
		if (!guid_Results.IsEmpty ()) {
			err = ACAPI_Element_SolidOperation_Create (guid_Results[0], guid_Operator2, APISolid_Add);
			if (err != NoError) {
				if (err == APIERR_NO3D)
					WriteReport_Alert ("Solid operation targets and operators can be freeshape elements only.");
				else
					WriteReport_Alert ("ACAPI_Element_SolidOperation_Create failed: %d", err);
			}
		}
	}

	return;
}

 

 

The ArchiCAD provided function ACAPI_Element_SolidOperation_Create only takes Morph object as target.
I want to know is there a way for us to pass a Wall ID to this function and create a opening in the target wall.

1 REPLY 1
roni
Booster

This documentation shows https://graphisoft.github.io/archicad-api-devkit/group___element.html#ga1a5d9501241379e03fb90fd8137a...
the operation can be done only between two morph elements.
Is there any other way to do Solid Element Operation between Wall and Morph?