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

How to access manufacturer data in Building Material

Anonymous
Not applicable
Hello,
I am currently trying to work with Building Materials.
First, I create a Building material and add it to the list. This works fine and all the information is there (including ID, manufacturer, description). However, when I try to access those, they are all NULL.

https://imgur.com/a/ZXjOfGI

Here is how I access the Building Materials:
	err = ACAPI_Attribute_GetNum(API_BuildingMaterialID, &count);
	if (err != NoError)
		return materials;

	for (i = 1; i <= count; i++) {
		BNZeroMemory(&attrib, sizeof(API_Attribute));
		attrib.header.typeID = API_BuildingMaterialID;
		attrib.header.index = i;
		err = ACAPI_Attribute_Get(&attrib);
        }
My question is what is the problem here? Why are those properties NULL?
1 REPLY 1
Viktor Kovacs
Graphisoft
Graphisoft
In case of id, manufacturer and description parameters Archicad fills these values only if they are pointing to an existing GS::UniString object. In your code all of them are null pointers, so they don't filled.

You can use something like this to make it work (it accesses only the manufacturer data, but should work for the other two as well):

API_Attribute attrib;
BNZeroMemory (&attrib, sizeof (API_Attribute));
attrib.header.typeID = API_BuildingMaterialID;
attrib.header.index = attributeIndex;

GS::UniString manufacturer;
attrib.buildingMaterial.manufacturer = &manufacturer;
ACAPI_Attribute_Get (&attrib);