The Global ARCHICAD Community

Stay informed. Get help. Share your knowledge.

Discussions about using GRAPHISOFT's tools (API DevKit) for independent software developers

Moderators: Karl Ottenstein, LaszloNagy, ejrolon, Barry Kelly, gkmethy, MOREH Tamas, Akos Somorjai, Ed Brown, Mihály Palenik, Tibor Lorántfy, rmasaki

Hi all,

I'm trying to change individual properties in Archicad. This is no problem with text fields, but I fail with SingleEmu.

prop is my API_Property Object and chaning value with singlevariant works flawless just by changing uniStringValue
Code: Select all
					GS::Array<API_SingleEnumerationVariant> listOfEnum = prop.definition.possibleEnumValues;
					for (UInt32 i = 0; i < listOfEnum.GetSize(); ++i) {
						API_SingleEnumerationVariant enumerator = listOfEnum[i];
						auto name_of_value = enumerator.displayVariant.uniStringValue.ToCStr();
						API_Guid guid_of_value = enumerator.keyVariant.guidValue;
						std::string test4 = name_of_value;
						if (test4 == "Teppich") {
							prop.value.singleEnumVariant = enumerator;
			error = ACAPI_Element_SetProperty(Guid, prop);
My naive idea is to rite through the possible enumerators here and as soon as I have found the suitable one (here the entry "Teppich") and then attach this singleEnumVariant to my property I write back

But its not working and i dont get any error code either. Any Ideas?

Best Regards

Hi Patrick,

I think you forgot to set the isDefault flag in the property object to false. If it remains true, than it does not matter how do you change the object because finally the element will still have the default value of the property.
Code: Select all
if (prop.definition.collectionType == API_PropertySingleChoiceEnumerationCollectionType &&
	prop.definition.valueType == API_PropertyStringValueType)
	for (const API_SingleEnumerationVariant& enumValue : prop.definition.possibleEnumValues) {
		if (enumValue.displayVariant.uniStringValue == "Teppich") {
			prop.value.singleEnumVariant = enumValue;

			prop.isDefault = false;
			error = ACAPI_Element_SetProperty(Guid, prop);