Project data & BIM
About BIM-based management of attributes, schedules, templates, favorites, hotlinks, projects in general, quality assurance, etc.
SOLVED!

Return NULL/UNDEFINED from property expression

PVBergkrantz
Expert

Hi, we are using a property that should return a length IF another (boolean) property is set. Basically if the other property is true that means this object has a certain sub object and its length should be calculated according to certain criteria.

 

I've managed to create a working IF clause basically like this:

 

IF (other_property = TRUE;

calculation for length;

0 mm)

 

But instead of returning 0 mm if the other property is false, I would simply like this property to return as undefined, or NULL or something like that.

| AC 25 Int | Win10 | i7-7800X | 32 GB | GeForce RTX 2060 6GB |

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

FALSE is basically a 0 while TRUE is a 1. So if you try to put FALSE as a result into your expression, it still has a value, while you intend to not have a value at all.

Thats why IFS is working. You just define, what happens if your condition is = TRUE, while not defining (undefined) what happens if your condition is = FALSE.

 

A bit offtopic but as a bit of additional information to IFS. It's still possible to define what happens, if your condition is = FALSE. It would like this:

IFS(Condition1; ValueIfTrue1; [Condition2; ValueIfTrue2];[...];[Conditionⁿ; ValueIfTrueⁿ]; TRUE; ValueIfNoConditionIsMet)

ArchiCAD 26 GER / Win10
Intel i9-9900K / 64GB RAM / nVidia GeForce RTX 2080 Ti

View solution in original post

8 REPLIES 8
Xandros
Expert

Hi

you might try the following:

 

IFS(other_property = TRUE;

calculation for length)

ArchiCAD 26 GER / Win10
Intel i9-9900K / 64GB RAM / nVidia GeForce RTX 2080 Ti
PVBergkrantz
Expert

Thank you, this works in this instance. But is there no more generalized way to return an undefined/null value? I don't know the syntax for this expression language. I did manage to achieve the same result by returning "FALSE", but it comes with the error "Data types and units must be identical for all predefined output values" and I'm slightly worried this might cause issues further down the line.

| AC 25 Int | Win10 | i7-7800X | 32 GB | GeForce RTX 2060 6GB |

You can't mix data types.

You are asking if a condition is true, then calculate the 'length', but if it is false you want a 'string' ("Null" or "Undefined").

I think the best you will get is to return a zero (0) length.

Then the data type will always be 'length' and you not get an error in the expression.

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
PVBergkrantz
Expert

Not quite, I don't want a string saying "Null" or "Undefined", I would simply like the value of this property to be undefined. When editing properties in objects there is the option to manually set a property as "undefined", and that makes it behave in a certain way. I would like to be able to set the property to undefined via an expression too.

PVBergkrantz_0-1709028718159.png

 

| AC 25 Int | Win10 | i7-7800X | 32 GB | GeForce RTX 2060 6GB |

OK then.

Can you set the default for that property as 'undefined'?

Then use the expression that Xandros suggested.

Then it will hopefully remain 'undefined' unless the expression is true.

I am not really sure as I haven't played a lot with expressions in this way.

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
PVBergkrantz
Expert

If i set the default to undefined then you can't use expressions. I'll use the expression Xandros suggested or FALSE, unless anyone else knows more. It is not critical to our project but I though I'd ask since many other programming languages have some version of NULL och Undefined that can be the value returned from functions. Thanks for the interest.

| AC 25 Int | Win10 | i7-7800X | 32 GB | GeForce RTX 2060 6GB |

Solution

FALSE is basically a 0 while TRUE is a 1. So if you try to put FALSE as a result into your expression, it still has a value, while you intend to not have a value at all.

Thats why IFS is working. You just define, what happens if your condition is = TRUE, while not defining (undefined) what happens if your condition is = FALSE.

 

A bit offtopic but as a bit of additional information to IFS. It's still possible to define what happens, if your condition is = FALSE. It would like this:

IFS(Condition1; ValueIfTrue1; [Condition2; ValueIfTrue2];[...];[Conditionⁿ; ValueIfTrueⁿ]; TRUE; ValueIfNoConditionIsMet)

ArchiCAD 26 GER / Win10
Intel i9-9900K / 64GB RAM / nVidia GeForce RTX 2080 Ti
PVBergkrantz
Expert

Thanks for the extended explanation!

| AC 25 Int | Win10 | i7-7800X | 32 GB | GeForce RTX 2060 6GB |