License delivery maintenance is planned for Saturday, July 26, between 12:00 and 20:00 CEST. During this time, you may experience outages or limited availability across our services, including BIMcloud SaaS, License Delivery, Graphisoft ID (for customer and company management), Graphisoft Store, and BIMx Web Viewer. More details…
2024-05-14 05:12 PM
Hello.
Please I need your assistance, I have been trying to write an expression for my Properties through the Archicad 27 C++ API, to sum two variables from the zone element. but I am yet to get the correct syntax. Please, any meaningful advice will be appreciated. Find below the code block snippet. Thank you.
//// Create expression property definitions for Area With Niches
API_PropertyDefinition expressionAreaWithNiches;
expressionAreaWithNiches.guid = APINULLGuid;
expressionAreaWithNiches.groupGuid = group.guid;
expressionAreaWithNiches.name = "Expression Area With Niches";
expressionAreaWithNiches.description = "This is the Room Area with recesses or niches";
expressionAreaWithNiches.collectionType = API_PropertySingleCollectionType;
expressionAreaWithNiches.valueType = API_PropertyRealValueType;
expressionAreaWithNiches.measureType = API_PropertyAreaMeasureType;
expressionAreaWithNiches.definitionType = API_PropertyCustomDefinitionType;
expressionAreaWithNiches.defaultValue.hasExpression = true;
expressionAreaWithNiches.defaultValue.propertyExpressions = {"SUM"{ "Measured Area", "Wall Inset Top Surface"} };
err = ACAPI_Property_CreatePropertyDefinition(expressionAreaWithNiches);
Solved! Go to Solution.
2024-05-16 04:26 PM
I played around and was able to figure out a working example. This code works for me (AC27):
API_PropertyDefinition expressionAreaWithNiches{};
expressionAreaWithNiches.guid = APINULLGuid;
expressionAreaWithNiches.groupGuid = group.guid;
expressionAreaWithNiches.name = "Expression Area With Niches";
expressionAreaWithNiches.description = "This is the Room Area with recesses or niches";
expressionAreaWithNiches.collectionType = API_PropertySingleCollectionType;
expressionAreaWithNiches.valueType = API_PropertyRealValueType;
expressionAreaWithNiches.measureType = API_PropertyAreaMeasureType;
expressionAreaWithNiches.definitionType = API_PropertyCustomDefinitionType;
expressionAreaWithNiches.canValueBeEditable = true;
expressionAreaWithNiches.defaultValue.basicValue.singleVariant.variant.type = expressionAreaWithNiches.valueType;
expressionAreaWithNiches.defaultValue.hasExpression = true;
expressionAreaWithNiches.defaultValue.propertyExpressions = {
"SUM ( ###Property:2FEF2535-7688-4A26-A0C8-2E892CBDCFD8###, ###Property:D53B1F63-5552-47FB-BD5B-FB1F57FEACEA### )"
};
err = ACAPI_Property_CreatePropertyDefinition (expressionAreaWithNiches);
Weirdly enough, the expression syntax I used in that code is reported as an incorrect expression syntax by ACAPI_Property_CheckPropertyExpressionString (available since AC27).
The following two syntax variations are accepted by ACAPI_Property_CheckPropertyExpressionString, but they don't work with ACAPI_Property_CreatePropertyDefinition!
"SUM ({Property:Zone / Measured Area}, {Property:Zone / Wall Inset Top Surface Area}) "
"SUM ( {Property:2FEF2535-7688-4A26-A0C8-2E892CBDCFD8}, {Property:D53B1F63-5552-47FB-BD5B-FB1F57FEACEA} )"
Seems like strange behavior. Is this intended @Akos Somorjai?
Best,
Bernd
2024-05-16 06:24 PM
Hi @Bernd - Archi-XT ,
Thanks for checking!
Using '{}' as separators doesn't work, but '###' does:
"SUM (###Property:Zone / Measured Area###, ###Property:Zone / Wall Inset Top Surface Area###)"
Best, Akos
2024-05-15 11:55 AM
Hi,
Could you please try:
expressionAreaWithNiches.defaultValue.propertyExpressions = {"SUM ( {Property:2FEF2535-7688-4A26-A0C8-2E892CBDCFD8}, {Property:D53B1F63-5552-47FB-BD5B-FB1F57FEACEA} )"};
Akos
2024-05-15 01:09 PM
Hello @Akos Somorjai , thank you for your response. I just tried it but it compiled without errors but it did not execute its task. Please, is this the expression property string GUIDS or what? Please. I await your feedback.
2024-05-15 01:15 PM
Hi,
Yes, they are. You can try to get the GUIDs if you create the same property in the Property Manager, then export it as an XML file.
2024-05-15 01:17 PM
OK. I will do that NOW... I will get back to you.
2024-05-15 01:34 PM
Hello @Akos Somorjai , I just tried it but it does not work. Or am I missing something? I really want to understand the expression syntax.
2024-05-16 04:03 PM
Hello? Is there any update or alternative please?
2024-05-16 04:26 PM
I played around and was able to figure out a working example. This code works for me (AC27):
API_PropertyDefinition expressionAreaWithNiches{};
expressionAreaWithNiches.guid = APINULLGuid;
expressionAreaWithNiches.groupGuid = group.guid;
expressionAreaWithNiches.name = "Expression Area With Niches";
expressionAreaWithNiches.description = "This is the Room Area with recesses or niches";
expressionAreaWithNiches.collectionType = API_PropertySingleCollectionType;
expressionAreaWithNiches.valueType = API_PropertyRealValueType;
expressionAreaWithNiches.measureType = API_PropertyAreaMeasureType;
expressionAreaWithNiches.definitionType = API_PropertyCustomDefinitionType;
expressionAreaWithNiches.canValueBeEditable = true;
expressionAreaWithNiches.defaultValue.basicValue.singleVariant.variant.type = expressionAreaWithNiches.valueType;
expressionAreaWithNiches.defaultValue.hasExpression = true;
expressionAreaWithNiches.defaultValue.propertyExpressions = {
"SUM ( ###Property:2FEF2535-7688-4A26-A0C8-2E892CBDCFD8###, ###Property:D53B1F63-5552-47FB-BD5B-FB1F57FEACEA### )"
};
err = ACAPI_Property_CreatePropertyDefinition (expressionAreaWithNiches);
Weirdly enough, the expression syntax I used in that code is reported as an incorrect expression syntax by ACAPI_Property_CheckPropertyExpressionString (available since AC27).
The following two syntax variations are accepted by ACAPI_Property_CheckPropertyExpressionString, but they don't work with ACAPI_Property_CreatePropertyDefinition!
"SUM ({Property:Zone / Measured Area}, {Property:Zone / Wall Inset Top Surface Area}) "
"SUM ( {Property:2FEF2535-7688-4A26-A0C8-2E892CBDCFD8}, {Property:D53B1F63-5552-47FB-BD5B-FB1F57FEACEA} )"
Seems like strange behavior. Is this intended @Akos Somorjai?
Best,
Bernd
2024-05-16 06:24 PM
Hi @Bernd - Archi-XT ,
Thanks for checking!
Using '{}' as separators doesn't work, but '###' does:
"SUM (###Property:Zone / Measured Area###, ###Property:Zone / Wall Inset Top Surface Area###)"
Best, Akos
2024-05-16 09:28 PM
Dear @Bernd - Archi-XT , that was my last thought. After I tried the suggestion of @Akos Somorjai ....I realised that every time I call the ACAPI_Property_GetPropertyExprReferenceString() function it gives me the ###......###.
Now you sent it...THANK YOU @Bernd - Archi-XT & @Akos Somorjai for your help. I am learning alot.