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.

Issues with rendering Objects through code(API_ObjectType)

kency
Booster

Hey team,

 

We have been trying to render an object through Archicad Add-on code. Issues found:

  1. Changing the fixPoint value does not change the object's position. We understand that the fix-point will be one of the several hotspots/points within the object that will be considered for the clicked position. However, when we change this value, it does not shift the object accordingly
  2. There is no change in rendering the object when the offset value is changed.
  3. There is a visual difference in the object when rendered through code and through the UI(Please refer to the screenshots)

 

 Is there anything that we are missing out on?

@BerndSchwarzenbacher  @Akos Somorjai 

Code:

 

 

 

GSErrCode CreateFurnitureElement()
{
	API_Element element = {};
	BNClear(element);
	SetAPIElementType(element, API_ObjectID);
	API_ElementMemo memo{};
	BNClear(memo);

	GSErrCode err = ACAPI_Element_GetDefaults(&element, &memo);
	if (err != NoError)
	{
		return err;
	}
	element.object.head.floorInd = 0;
	Int32 libInd = GetLibraryIndex("Sofa L-Shape 03 26", APILib_ObjectID);
	if (libInd > 0)
	{
		element.object.libInd = libInd;
		element.object.pos = {2,2};
		element.object.angle = 0;
                element.object.level = 0;
                element.object.fixPoint = 1;
                element.object.useXYFixSize = false;
                element.object.offset = {1,1};
                element.object.xRatio = 1;
                element.object.yRatio =1;

		err = ACAPI_Element_Create(&element, &memo);
		if (err != NoError)
		{
			return err;
		}
		return NoError;
	}
	throw std::runtime_error("Furniture not found");
}

 

 

 

 Rendered through UI

renderedThroughUI.png

 

 

Rendered through code

renderedThroughCode.png

  

Thank you!

2 REPLIES 2

Hi Kency,

 

About 1 & 2: I think from the API point of placing an object, you have to specify pos where you want the origin (0,0,0) of the GDL object to be.
My suspicion is, that offset then might give you the distance of the clicked point to the actual position of the GDL origin as an output. That then depends on the fixPoint if that's not at the GDL object's origin. I think offset is not available as an input for API calls.
But all of this is just a guess how it works, I don't have time to confirm this right now.

 

About 3: Is the difference only in the material display or is there something else I'm missing? Also what do you mean exactly by "rendered through code" vs. "rendered through ui"?


Best,
Bernd

 

 

 

Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website: Archi-XT.com

1. For the fixPoint what I meant was with the pos value set to 0,0,0 and then just changing the fixPoint does not shift the object. Our understanding is that the position will be aligned to the fixPoint set. (For example, if the fixPoint is one of the corners of the object, the pos (0,0,0) will be set for that corner).

 

2. Offset is provided in the API documentation. But did not understand its relevance and it did not change the positioning of the object.

 

3. There is a visual difference. What I meant by "rendered through code" is the one on the left was placed by triggering the add-on that we have written(the snippet is shared in the first post) and "Rendered through UI" means we placed the exact same object through the archicad UI after the add-on execution.

Learn and get certified!