We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

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

Expression Based Properties in AC 27 API

Apollos
Booster

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);

 

 

 
2 ACCEPTED SOLUTIONS

Accepted Solutions
Solution

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

View solution in original post

Solution

Hi @BerndSchwarzenbacher ,

 

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

 

 

View solution in original post

9 REPLIES 9
Akos Somorjai
Graphisoft
Graphisoft

Hi,

 

Could you please try:

expressionAreaWithNiches.defaultValue.propertyExpressions = {"SUM ( {Property:2FEF2535-7688-4A26-A0C8-2E892CBDCFD8}, {Property:D53B1F63-5552-47FB-BD5B-FB1F57FEACEA} )"};

 

Akos

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.

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.

 

OK. I will do that NOW... I will get back to you.

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.

Hello? Is there any update or alternative please?

Solution

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

Solution

Hi @BerndSchwarzenbacher ,

 

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

 

 

Dear @BerndSchwarzenbacher , 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 @BerndSchwarzenbacher  & @Akos Somorjai  for your help. I am learning alot.