cancel
Showing results for 
Search instead for 
Did you mean: 
EN
cancel
Showing results for 
Search instead for 
Did you mean: 
PVBergkrantz
Expert

Return NULL/UNDEFINED from property expression

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 29 Int | Win11 | i7-7800X | 32 GB | GeForce RTX 2060 6GB |

1 Solution

Accepted Solutions
Xandros
Advisor

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 27 GER / Win10
Intel i9-9900K / 64GB RAM / nVidia GeForce RTX 2080 Ti

Go to post

8 Replies 8
Xandros
Advisor

Hi

you might try the following:

 

IFS(other_property = TRUE;

calculation for length)

ArchiCAD 27 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 29 Int | Win11 | i7-7800X | 32 GB | GeForce RTX 2060 6GB |

Barry Kelly
Moderator

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
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), 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 29 Int | Win11 | i7-7800X | 32 GB | GeForce RTX 2060 6GB |

Barry Kelly
Moderator

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
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), 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 29 Int | Win11 | i7-7800X | 32 GB | GeForce RTX 2060 6GB |

Xandros
Advisor

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 27 GER / Win10
Intel i9-9900K / 64GB RAM / nVidia GeForce RTX 2080 Ti
PVBergkrantz
Expert

Thanks for the extended explanation!

| AC 29 Int | Win11 | i7-7800X | 32 GB | GeForce RTX 2060 6GB |

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!