cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
Archicad C++ API
About Archicad add-on development using the C++ API.

How to add IFC property to an element in AC29

nevim
Participant

Hello, I recently took on plugin development and there was a function for creating new IFC properties.

Unfortunately I didn't find any function in IFCAPI that can attach a IFCAPI::Property to an element

The function in question:

void CApplyOnSelection::changeIFCProperty(const API_Guid & guid, const GS::UniString & propertyName, const GS::UniString & propertyType, const GS::UniString & propertySet, const std::string & value) {
GSErrCode err;
API_IFCProperty* newProperty = new API_IFCProperty;
newProperty->singleValue.nominalValue.value.stringValue = value;
newProperty->singleValue.nominalValue.valueType = propertyType;
newProperty->head.propertyName = propertyName;
newProperty->head.propertyType = API_IFCPropertySingleValueType;
newProperty->head.propertySetName = propertySet;
err = ACAPI_Element_SetIFCProperty(guid, *newProperty);
WriteReport_End(err);
}

Thanks in advance

1 REPLY 1

IFC properties could previously be added to an element with ACAPI_Element_SetIFCProperty. This was deprecated in AC28 and removed in AC29. The new approach is to use IFC hooks to dynamically declare what IFC properties should be attached to an element on demand (e.g. for IFC export or for a UI display).

 

ACAPI_Element_SetIFCProperty statically attaches data to project elements and can often extremely verbose and/or repetitive, which can lead to slow, bloated projects. And frequently this data already exists somewhere else, e.g. an external database. Using hooks enables an add-on to attach or extract IFC data at the point of export or import. GS is forcing this approach by removing the functions that add/remove IFC properties directly to/from elements.

 

Take a look at the HookManager, e.g. GetHookManager::RegisterPropertyHook. The example project IFCHook_Test is helpful.

Ralph Wessel BArch
Central Innovation