Formula, doesn't calculate right!


#1

I can’t figure out why the sizes over 89 doesn’t come out with 50?? (thouse marked with red)

Capture


#2

The formula should be

if(x<=18,20,(if(x<=28,30,(if(x<=54,40,(if(x<=61,50,(if(x<=89,40,(if(x<=350,50,false)))))))))))

or

x<=18?20:(x<=28?30:(x<=54?40:(x<=61?50:(x<=89?40:(x<=350?50:false)))));


#3

Thanks Vikram

But it didn’t solve my situation.If I added a code block before the Formula the result where right.

It is like if the number is over 100 then it starts from the beginning again!!

I don’t know if it could be because it’s with 3 numbers?? (a guess)


#4

Jorgen,

It actually does work alright even with your list

The problem with your formula is the position of the brackets.

If you just copy one of the formulas I’ve provided earlier and replace yours, it should work the way you expect it to.

Below is an example with a list similar to what is visible in your screen grab.


#5

Hi

As you can see it does not work. I’ve added your suggestions. But Thanks for the try

Capture1

 

 


#6

Did you try flattening the list before feeding it to the formula?

Also, I’m using this build. The latest available.


#7

Dimitar Venkov’s comment in this post regarding the IF node and Dynamo versions might be relevant to your case.


#8

Hi

I have updated to the latest version of Dynamo… but it wasn’t the solution.

I have tried with a more simple formula, 2 times with different values… I think now that it could be something with my units??? or??

Capture2


#9

It seems to be considering only the first two digits.

Why don’t you report the issue here?


#10

Hi Vikram

I’ve reported it. :slight_smile:


#11

Hi Jørgen

Interesting issue, you found in Dynamo. Can I ask what element and parametername are you look up with Element.Get.ParameterValueByName? When I try the formula if(x<=18,20(if(x<=28,30,(if(x<54,40,(if(x<=61,50,(if(x<=89,40(if(x<350,500,false))))))))))) with a number slider then the formula works correct. If I try with Categori (wall) and Parameter (Area) then the formula also works correct. I then wonder if it is the data, you bring to the formula, that Dynamo has an issue to read.

Palle Bisgaard

 


#12

Hi Palle

It’s Pipe sizes from the Category “PipeInsulations”


#13

Hi Jørgen

The issue for Dynamo is that the size number are redden as text and therefore you need to change it to a number. In the attached file, you will be able to see how we have splinted up the text list and converted into numbers.

If issue

Palle Bisgaard


#14

guys i followed your discussion and suppose that the problem lies again in dynamos’ / revits’ unit conversion capabilities.

you guys are most propably working in millimeters but still (0.82xx) dynamo extracts inches.

as you can see when transferred from millimeters to inches and back the result is correct even for values >100

pipe


#15

I managed to solve my problem. Thanks for the help

I’ve solved my problem with putting in the box “String.ToNumber” before the formula.