# Conditional output using dynamo

**URL:** <https://forum.dynamobim.com/t/conditional-output-using-dynamo/83136>\
**Category:** Revit\
**Tags:** revit, python, dynamo\
**Created:** [November 15, 2022, 12:02pm UTC](https://forum.dynamobim.com/t/conditional-output-using-dynamo/83136 "2022-11-15T12:02:29Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![fkp7057](https://avatars.discourse-cdn.com/v4/letter/f/da6949/32.png) [@fkp7057](https://forum.dynamobim.com/u/fkp7057)\
**Post date:** [November 15, 2022, 12:02pm UTC](https://forum.dynamobim.com/t/conditional-output-using-dynamo/83136/1 "2022-11-15T12:02:29Z")

</div>

Hello,

As you can see in below snap i have listed values using dynamo.  
Now i want to create another list based on the list shown in snap.  
for example

1. if value between 0 to 150 then it should be AA.
2. 151 to 200 are AB
3. 201 to 300 are AC.  
I have tried IF node but it is not useful in this case .

if any one can guide me on this it would be very helpful for me…  
range in list are from -1130 to 5500.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/2/422d66194433ac3456f290dd943bb3c3708ffcac.png)

---

<div class="post-metadata">

**Author:** ![Garbage\_Collector](https://avatars.discourse-cdn.com/v4/letter/g/da6949/32.png) [@Garbage\_Collector](https://forum.dynamobim.com/u/Garbage_Collector)\
**Post date:** [November 15, 2022, 12:35pm UTC](https://forum.dynamobim.com/t/conditional-output-using-dynamo/83136/2 "2022-11-15T12:35:05Z")

</div>

You could use two if statements in a row, one to figure out if its above or below 150, and if its above then do an if statement for 150-200 or 200-300.

I’d probably just write a small python script with two if statements

---

<div class="post-metadata">

**Author:** ![fkp7057](https://avatars.discourse-cdn.com/v4/letter/f/da6949/32.png) [@fkp7057](https://forum.dynamobim.com/u/fkp7057)\
**Post date:** [November 15, 2022, 1:42pm UTC](https://forum.dynamobim.com/t/conditional-output-using-dynamo/83136/3 "2022-11-15T13:42:31Z")

</div>

In the post, I just put an example… I have so many conditions… it might be around 50-60…  
I have tried using python script … it is work with one input … but ho two use the same python script for each individual list items

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [November 15, 2022, 1:43pm UTC](https://forum.dynamobim.com/t/conditional-output-using-dynamo/83136/4 "2022-11-15T13:43:34Z")

</div>

Hello,  
here is a possibility to approach things if you have a lot of nested ifs given the length of the study range

Turned into a geometry problem  
(the base from 0 to 10)  
You still have to make a decision on the border zone between beaches

There is surely a custom node that allows this I think (but I do not know it)

 ![15 Novembre forum anglais rep2_2022-11-15_02-35-24](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/d/cd8d58316aa150e3b09956342281466535754b88.png)

good vision  
script:  
[15 Novembre forum anglais rep2.dyn](https://forum.dynamobim.com/uploads/short-url/7oedFDE5n2DReAL08MTIcgGdJgE.dyn) (30.9 KB)

Cordially  
christian.stan

---

<div class="post-metadata">

**Author:** ![fkp7057](https://avatars.discourse-cdn.com/v4/letter/f/da6949/32.png) [@fkp7057](https://forum.dynamobim.com/u/fkp7057)\
**Post date:** [November 15, 2022, 1:52pm UTC](https://forum.dynamobim.com/t/conditional-output-using-dynamo/83136/5 "2022-11-15T13:52:12Z")

</div>

Thank you for your response.

I will try the way you have shown in the image.  
But I have many elements in my model… based on element location I have made a list of X and Y coordinates.  
Now I want to add parameters based on X or Y coordinates.

as posted in 3rd post… have 50-60 conditions. it will have many nested IFs

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [November 15, 2022, 2:06pm UTC](https://forum.dynamobim.com/t/conditional-output-using-dynamo/83136/6 "2022-11-15T14:06:37Z")

</div>

Properly said: I used 10 boxes (from 0 to 1 …9 to 10, 10 lines here and projection of a point on one of them or not)  
Your “boxes” of storage will have to be written at one time or another if they are regular, you can automate.

I think you have to make a function (it all depends on your skills, either in designscript or python)

Cordially  
christian.stan

---

<div class="post-metadata">

**Author:** ![gilberto.arechigaiba](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gilberto.arechigaiba/32/204980_2.png) [@gilberto.arechigaiba](https://forum.dynamobim.com/u/gilberto.arechigaiba)\
**Post date:** [November 15, 2022, 2:24pm UTC](https://forum.dynamobim.com/t/conditional-output-using-dynamo/83136/7 "2022-11-15T14:24:23Z")

</div>

Hola Amigo @fkp7057 buenas. Is mandatory evaluate positions? the easy way to me is create your list and imposs the values, the other option is transform values to string and use String.Contains to evaluate if match the values ranges, Hope this ideas help you!

 ![Concatenate Nums by condition](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/f/5f27c949bc7e6fc3bbd73a4d0026c538e2481f2c.jpeg)  
[Concatenate List and strings.dyn](https://forum.dynamobim.com/uploads/short-url/9D3jKEpEfbIRh2TxlBg0J9Rp0oJ.dyn) (47.1 KB)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [November 15, 2022, 2:49pm UTC](https://forum.dynamobim.com/t/conditional-output-using-dynamo/83136/8 "2022-11-15T14:49:04Z")

</div>

You need to create a conditional statement either in python (with list comprehension so it iterates for each item) or in a code block using DesignScript (which will iterate automatically).

The shorthand for a conditional If statement in DesignScript is  
`condition ? returnTrue : returnFalse;`  
and reads as “If `condition` is true then `returnTrue` else `returnFalse`.”

You can stack multiple conditions by nesting a new If statement inside a `returnTrue` or `returnFalse` value.

---

<div class="post-metadata">

**Author:** ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)\
**Post date:** [November 15, 2022, 3:24pm UTC](https://forum.dynamobim.com/t/conditional-output-using-dynamo/83136/9 "2022-11-15T15:24:59Z")

</div>

If you only have the three intervals you described you can use this: (in a Code Block)

```auto
Input >= 0 && Input <= 150 ? AA :
Input > 150 && Input <= 200 ? AB :
Input > 200 && Input <= 300 ? AC : "n/a";

```

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [November 15, 2022, 4:20pm UTC](https://forum.dynamobim.com/t/conditional-output-using-dynamo/83136/10 "2022-11-15T16:20:36Z")

</div>

I ma

 ![15 Novembre forum anglais rep2bis_2022-11-15_05-22-12](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/2/02889de63cb94b860d249836819c51efbf495280.png)  
de an example to make it clearer.

function:

```auto
def proj(plage:var[],point_test:var[])
{
x=PolyCurve.ByPoints(
Point.ByCoordinates(plage,0,0));

x_cut=PolyCurve.Curves(x);

test_P=Point.ByCoordinates(point_test,-1,0);

P_proj=Point.Project(test_P,x_cut<1>,
Autodesk.Geometry.Vector.ByCoordinates(0,1,0));

return= P_proj;
};

```

Cordially  
christian.stan

---

<div class="post-metadata">

**Author:** ![fkp7057](https://avatars.discourse-cdn.com/v4/letter/f/da6949/32.png) [@fkp7057](https://forum.dynamobim.com/u/fkp7057)\
**Post date:** [November 16, 2022, 3:40am UTC](https://forum.dynamobim.com/t/conditional-output-using-dynamo/83136/11 "2022-11-16T03:40:37Z")

</div>

Thank you for your simple solution… its worked for me…

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/6/866ead2187e0a45384cdd3d3030e27dbdfd338d9.png)

the same way i have tried using python but it worked for one value not for list… (ay be something has to do in python).

I would like to thanks all who have put their effort to solve my queries. but @Daan solution was easy for me.
