cancel
Showing results for 
Search instead for 
Did you mean: 
EN
cancel
Showing results for 
Search instead for 
Did you mean: 
larsr
Participant

IFCAPI::PropertyAccessor::GetAttributes issue in custom add‑on

Hello!

Does the new IFCAPI have any prerequisites that need to be set in order to be used? The code provided below, if added to the example project IFC_Test, will print:

TestApi(): 1
TestApi(): 2
TestApi(): 3
Number of attributes: 6
Attribute Name0: GlobalId
Attribute Name0: Name
Attribute Name0: Tag
Attribute Name0: PredefinedType

However, the same code in my add‑on returns 0 attributes:

TestApi(): 1
TestApi(): 2
TestApi(): 3
Number of attributes: 0


Archicad version: 29.2.0 (5003)
SDK version: WIN.29.3100

Test function:

void TestApi()
{
	GS::Array<API_Neig> aSelection;
	API_SelectionInfo rSelectionInfo = {};
	ACAPI_Selection_Get(&rSelectionInfo, &aSelection, false);
	for (auto& rNeig : aSelection)
	{
		API_Elem_Head head{};
		head.guid = rNeig.guid;
		auto objectID = IFCAPI::GetObjectAccessor().CreateElementObjectID(head);
		//
		DBPrintf("TestApi(): 1\n");
		if (objectID.IsErr())
		{
			ACAPI_WriteReport("TestApi(): CreateElementObjectID failed for element ", true);
			return;
		}
		//
		IFCAPI::PropertyAccessor propertyAccessor = IFCAPI::PropertyAccessor(objectID.Unwrap());
		auto properties = propertyAccessor.GetAttributes();
		if (properties.IsErr())
		{
			ACAPI_WriteReport("TestApi(): GetAttributes failed for element", true);
			return;
		}
		DBPrintf("TestApi(): 2\n");
		//
		auto oIfcAttributes = properties.Unwrap();
		DBPrintf("TestApi(): 3\n");
		DBPrintf("Number of attributes: %zu\n", oIfcAttributes.size());
		//
		for (auto& rIfcAttribute : oIfcAttributes)
		{
			if (rIfcAttribute.GetName().IsEmpty()) continue;
			//
			if (!rIfcAttribute.GetValue().has_value()) continue;
			//
			DBPrintf("Attribute Name0: %s\n", rIfcAttribute.GetName().ToCStr().Get());
		}
	}
}

 

Operating system used: Windows 11 25H2

0 Replies 0

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!