cancel
Showing results for 
Search instead for 
Did you mean: 
EN
cancel
Showing results for 
Search instead for 
Did you mean: 
Apollos
Booster

Expression Based Properties in AC 27 API

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 Solutions

Accepted Solutions

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

Automating Archicad with Add-Ons, GDL-Objects & Python Archi-XT.com

Go to post

Akos Somorjai
Graphisoft
Graphisoft

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

 

 

Go to 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

Apollos
Booster

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.

Akos Somorjai
Graphisoft
Graphisoft

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.

 

Apollos
Booster

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

Apollos
Booster

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.

Apollos
Booster

Hello? Is there any update or alternative please?

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

Automating Archicad with Add-Ons, GDL-Objects & Python Archi-XT.com
Akos Somorjai
Graphisoft
Graphisoft

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

 

 

Apollos
Booster

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.

 

 

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!