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

User avatar
By kzaremba
#288029
I'm trying to create automatically prop with expression from an addon. I checked the examples and which is able to CONCAT strings. I would like to use values form AC is it possible to indicate AC params in Expression over the code.

What I found out is that simple copy paste of values gives:
{Property:Zone/Zone Category}
xml export gives guid:
{Property:C55E9728-EB60-40A2-AA76-77B061FA4ADA}

Both didn't work out in the code any suggestions?
User avatar
By kzaremba
#289402
I would appreciate the suggestion for this problem. Our expressions are growing and it's hard to manage them with builtin editor - especially that it doesn't save editing info like enter, tab etc.

In attachment one of longest definitions so you can see how problematic it can be. We decided to make it as property expression not script because it used to be easier for other team members to modify simple stuff.

Sorry for low resolution but there is sensitive info for the project so I'm obliged to make it unreadable. If anyone is interested in what it does and how it works I'm happy to make and share the modified neutral version. Let me know.
Attachments
longestexpressionever.jpg
User avatar
By poco2013
#289419
I agree that you just demonstrated the fallacy of inventing a new language over using a script language like -- Python for expressions. But more of a problem is the limitation of data access in expressions and the restriction of expressions to only one element and one return data value..

However, there are two approaches to mitigate your long Expressions. You might try breaking up the expressions into smaller ones which calculate only parts of the formula. Then bring them together using one or two final expressions using those smaller Expressions. Expressions can reference Expressions. The downside is that the applicable element must reference all expression parts whether there needed or not, which can become cumbersome. But they can all be grouped into one grouping. Also, It may be possible to use the sequence feature in the expression, whereby the program selects the applicable Expression based on element type. if you were more definitive in your problem, you would get more suggestions. Using the addon API to create expressions would be counter- productive. The problem there is that Expressions and properties contain a unique GUID embedded,which Graphisoft has not chosen to reveal the format, at least, not yet. IMHO.

On a side note, you can use a external editor and copy/paste the result by including the directory path of the properties. The Expression editor, upon reading it will automatically choose the correct property and GUID.
User avatar
By kzaremba
#289423
limitation of data access
That's true I suppose it's some safety reasons for it :D. Still, it's better to have expressions than before. We used to do even simple CONCAT with addon :D.

I would also add lack of support for list and tag type properties.
try breaking up the expressions into smaller ones
This is what we actually do. We are trying to encapsulate some functionalities in numerous properties Espattialy for conversions, text manipulations etc . This example, however, is one big IF statement choosing different categories based on element names and other properties.

What we actually do for editing this stuff we use Notepad++ and copy paste expression. This helps to track closing functions.
The reason I would like to know how it works and how property is referenced is Idea for a custom editor for expression so we can prepare our own tool for building up and edit more complex logic.
User avatar
By Akos Somorjai
#289528
This is maybe a dump question, but have you checked the Property_Test add-on? There's a TestXMLImport() function which creates an expression referring to another property:

"<Expression>9 + {Property:Property_Test Add-On Group/Property2}</Expression>"

We don't have a catalogue of all properties, as the user may also create his/her own.

Regatds, Akos
User avatar
By kzaremba
#289541
but have you checked the Property_Test add-on
Hi Akos, Yes I have checked both examples in AC22 DevKit. As I mentioned in the first post I have tried to use this kind of referencing property in function based on SimpleTestPropertiesWithExpressions().

It didn't work out. Without referencing property it was working. If you are asking I suppose that it should work with this syntax {Property:Property_Test Add-On Group/Property2}
I will double check that then. Thanks.
User avatar
By Akos Somorjai
#289583
but have you checked the Property_Test add-on
Hi Akos, Yes I have checked both examples in AC22 DevKit. As I mentioned in the first post I have tried to use this kind of referencing property in function based on SimpleTestPropertiesWithExpressions().

It didn't work out. Without referencing property it was working. If you are asking I suppose that it should work with this syntax {Property:Property_Test Add-On Group/Property2}
I will double check that then. Thanks.
Thanks, I figured, just to be on the safe side :)

The original plan was to make it simple, so theoretically it should work with the readable expressions. Tell me if it fails...

We added to functions that may help: ACAPI_Goodies (APIAny_CheckPropertyExpressionStringID, ...) and ACAPI_Goodies (APIAny_GetPropertyExprReferenceStringID, ...).

Best, Akos