BIM Coordinator Program (INT) April 22, 2024
Find the next step in your career as a Graphisoft Certified BIM Coordinator!
Archicad C++ API
About Archicad add-on development using the C++ API.

Unable to rotate an Opening Element through C++ code


Hi Team,

We were able to create an opening that is not rotated through code as shown below:

Screenshot 2024-02-28 101418 (1).png

But when we tried to create an opening in a wall that is rotated, it gave us an exception.

Screenshot 2024-02-28 101446.png

We tried to apply the same values of a rotated opening by examining the element while debugging, but it threw an Undefined Exception. The fields that we observed while debugging were:

  • element.opening.extrusionGeometryData.frame
  • element.opening.extrusionGeometryData.parameters.anchorAltitude

Even even after applying the exact values, the opening creation failed. Sharing the code snippet:


GSErrCode CreateVoidElement(API_Guid &guid, double height, double width) {
	API_Element element = {};
	SetAPIElementType(element, API_OpeningID);
	GSErrCode err = ACAPI_Element_GetDefaults(&element, nullptr);
	if (err != NoError) {
	   return err;
	API_Coord3D centre = {
	element.opening.owner = guid;
	element.opening.extrusionGeometryData.frame.basePoint = centre;
	element.opening.extrusionGeometryData.parameters.width = width;
	element.opening.extrusionGeometryData.parameters.height = height;
	element.opening.extrusionGeometryData.parameters.anchorAltitude = centre.z;
	element.opening.extrusionGeometryData.parameters.basePolygonType = API_OpeningBasePolygonRectangular;
	element.opening.extrusionGeometryData.parameters.linkedStatus = API_OpeningNotLinked;
	element.opening.extrusionGeometryData.parameters.limitType = API_OpeningLimitInfinite;

	element.opening.extrusionGeometryData.frame.axisX = { 0.68026102118532772,-6.2630543774511271,-0.73296994689816253 };
	element.opening.extrusionGeometryData.frame.axisY = { 0.73296994689816231,1.8257846755738153,0.68026102118532794 };
	element.opening.extrusionGeometryData.frame.axisZ = { 0.0,1.0,0.0 };

	err = ACAPI_Element_Create(&element, nullptr);
	return err;


cc: @BerndSchwarzenbacher @Akos Somorjai @navnit 

Learn and get certified!