"IF" function HELP

I’m trying to show a text and for that I use the “IF” function. If the result you want to be TRUE or FALSE is written in quotation marks ("") then Sketchup understands that this should literally be shown as a text, EVEN IF THIS TEXT CONTAINS THE COMMA SYMBOL, as shown in Figure 1. So far so good.

The problem is when I try to put another “IF” function within the existing “IF” function, the program no longer understands that the comma symbol (which is a text and is enclosed in quotation marks) should be literally written, and not that it is there to separate what is TRUE or FALSE. Figure 2.

What is "Cama!" referring to ? (ie, I did not think that the DC functions where multi-lingual.)

“cama” in Portuguese (Brazil) means “bed”. Yes, Sketchup is not multi-lingual, but the program should still not understand the content of the “IF” function in one way and present another result at another time

…and “Tamanho” means “size” :smiley:

Ah … okay the images are not showing the “Cama” level header ?
Why not use "Parent!" ?

What happens if your expression uses %2C in place of the literal commas?

I like Dan’s answer if it works.

Also try turning the comparison around. Something like this. Worth a try.

=IF(NOT(Cama!Tamanho="SPeq"),IF(Cama!Tamanho="Cas","0,88 x 1,88",0), "0,78 x 1,88")

Sketchup will understand this as a “point”

I think that writing this way the program will not show the changes as I wish… but thank you

It might be best to share the DC as there many ways to achieve a result, however you could use extra attributes to preserve your options like tam1, tam2,…
sizes with comma.skp (20.3 KB)

Does &quote; works?

Honestly I never used the “&” … I would like to know a useful practical situation for that :slight_smile:

This is a good alternative … but I am still intrigued as to why it sometimes works and sometimes not, since the mathematical operators and the logic of writing remain the same.

I created another Dynamic Component containing the exact problem I’m experiencing. I hope I have clarified my question and I will be very happy if anyone can help :wink:

IF bug.skp (123.7 KB)
Use the Component Attributes combined with the Component Opitions

Thank you guys!

I have another question: how do I add text after a formula? Should I use the “&”, “;”, “,”, “and” or some other symbol?

=round(lenx,2) & “cm”

2 Likes

Thank you @pcmoor

It is because the DC extension is not a computer language like Ruby or C, it is an extension (written in Ruby) that evaluates user input and parses or tried to translate that into their built in methods or modules. Most likely it starts from left to right and gets confused if the output isn’t a number but text. It will then evaluate the ‘nested’ as text_to_number and use that outcome in the higher ones. We don’t know exactly, because it is not public.

I prefer choose above nested If.

1005/5000
Ok … this seems to be more complicated than I think it is …

I am experiencing other components with different problems of reading the attributes but similar to this one. For example: I use units in “cm” instead of “inch”, so far ok. When I tell the program that a certain attribute must be in “cm”, within the same sequence of 4 nested “IF” functions, 3 work but one of them is simply that the program does not recognize and does not return any results. I tried to change the units from “cm” to “decimal number” and then everything worked correctly. As a test, I also tried to write the same nested sequence containing the 4 “IF” but instead of using the criterion “= IF (Nnn! Nnn = 64, …)” I changed it to "= IF (Nnn! Nnn <64, …) “and now, even the program doesn’t understand the functions due to the fact that the units like” cm "it understood correctly and started showing the result I expected … I can’t understand it …

If you want, later I can make the component available for you

Thank You