# Changing Family Based on Parameter Value

**URL:** <https://forum.dynamobim.com/t/changing-family-based-on-parameter-value/16147>\
**Category:** Uncategorized\
**Created:** [November 1, 2017, 2:07pm UTC](https://forum.dynamobim.com/t/changing-family-based-on-parameter-value/16147 "2017-11-01T14:07:05Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![robertsb2010](https://avatars.discourse-cdn.com/v4/letter/r/7c8e57/32.png) [@robertsb2010](https://forum.dynamobim.com/u/robertsb2010)\
**Post date:** [November 1, 2017, 2:07pm UTC](https://forum.dynamobim.com/t/changing-family-based-on-parameter-value/16147/1 "2017-11-01T14:07:05Z")

</div>

Hey everyone, I need some help. I have been trying to find a way to change a family type based on a parameter value and I am having trouble. In this script, I find the “specified supply airflow” and then divide it among all diffusers in a space. I’d like to give cfm ranges and automatically have the family change to the correct type based on what range it falls in. I was thinking the “if” node, but can’t seem to get it to function how I’d like. Any help is appreciated. I’ve attached the dynamo file and a screenshot.

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/f/8f3a585ec06eee5a7456cf5ae3d1b733a35a7963.PNG)  
[Apply CFM across ATs.dyn](https://forum.dynamobim.com/uploads/short-url/eboLGAc4y6ILqmGjQB9xwrn0qSt.dyn) (21.8 KB)

---

<div class="post-metadata">

**Author:** ![Ewan\_Opie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ewan_opie/32/77070_2.png) [@Ewan\_Opie](https://forum.dynamobim.com/u/Ewan_Opie)\
**Post date:** [November 1, 2017, 9:19pm UTC](https://forum.dynamobim.com/t/changing-family-based-on-parameter-value/16147/2 "2017-11-01T21:19:41Z")

</div>

If it is a numerical range or number you are using to define the inputs, then this may work for you.  
 ![Multiple Inputs](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/6/961791f4ba56be345eb3a53a68ff995f739a17b9.gif)

---

<div class="post-metadata">

**Author:** ![robertsb2010](https://avatars.discourse-cdn.com/v4/letter/r/7c8e57/32.png) [@robertsb2010](https://forum.dynamobim.com/u/robertsb2010)\
**Post date:** [November 2, 2017, 1:19pm UTC](https://forum.dynamobim.com/t/changing-family-based-on-parameter-value/16147/3 "2017-11-02T13:19:02Z")

</div>

Thanks for the response! I’m going to try this out and see if it gets me where I want to be.

UPDATE: When I try this, it runs without error, but doesn’t change any families inside the revit file.

---

<div class="post-metadata">

**Author:** ![Ewan\_Opie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ewan_opie/32/77070_2.png) [@Ewan\_Opie](https://forum.dynamobim.com/u/Ewan_Opie)\
**Post date:** [November 2, 2017, 9:33pm UTC](https://forum.dynamobim.com/t/changing-family-based-on-parameter-value/16147/4 "2017-11-02T21:33:38Z")

</div>

I have shown Strings as inputs/outputs. Are you feeding actual family types into the inputs?  
 ![ezgif-3-17989dfac9](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/7/f7201e2ed6c6e3510d287d1f72420fd0b9ebf345.gif)

---

<div class="post-metadata">

**Author:** ![robertsb2010](https://avatars.discourse-cdn.com/v4/letter/r/7c8e57/32.png) [@robertsb2010](https://forum.dynamobim.com/u/robertsb2010)\
**Post date:** [November 3, 2017, 3:03pm UTC](https://forum.dynamobim.com/t/changing-family-based-on-parameter-value/16147/5 "2017-11-03T15:03:56Z")

</div>

That’s what I tried. That’s the end goal is to select actual families based on parameter values that are pulled from the revit file.

The entire script reads “specified supply airflow” of a space and divides that among all the diffusers it finds within a space. I would like to take the divided values and auto pick a family based on a given cfm range (i.e. select Family 1 if cfm is between 0-120 cfm, etc.)

Also, could you elaborate a little on what exactly that code block is doing? I get the general idea, but I’m a little inexperienced with code blocks.

---

<div class="post-metadata">

**Author:** ![Ewan\_Opie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ewan_opie/32/77070_2.png) [@Ewan\_Opie](https://forum.dynamobim.com/u/Ewan_Opie)\
**Post date:** [November 3, 2017, 9:45pm UTC](https://forum.dynamobim.com/t/changing-family-based-on-parameter-value/16147/6 "2017-11-03T21:45:26Z")

</div>

All good.  
I am out of the office for a couple of days. I’ll get something on range input posted when I get back as I also have an idea on how to do this with OOTB nodes.

Unless there are any other ideas from the forum? Python gurus? 😉

---

<div class="post-metadata">

**Author:** ![Yna\_Db](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/yna_db/32/30641_2.png) [@Yna\_Db](https://forum.dynamobim.com/u/Yna_Db)\
**Post date:** [November 3, 2017, 10:00pm UTC](https://forum.dynamobim.com/t/changing-family-based-on-parameter-value/16147/7 "2017-11-03T22:00:49Z")

</div>

> [@robertsb2010](#):
>
> what exactly that code block is doing?

That code block holds a conditional statement (similar function as an _if_ node), see here:  
[http://dynamoprimer.com/en/07\_Code-Block/7-3\_shorthand.html](http://dynamoprimer.com/en/07_Code-Block/7-3_shorthand.html)

This conversation could also bring additional clues:

> [@Replacing a number of selected elements with another family type keeping original dimensions](https://forum.dynamobim.com/t/replacing-a-number-of-selected-elements-with-another-family-type-keeping-original-dimensions/8315/2):
>

---

<div class="post-metadata">

**Author:** ![Ewan\_Opie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ewan_opie/32/77070_2.png) [@Ewan\_Opie](https://forum.dynamobim.com/u/Ewan_Opie)\
**Post date:** [November 4, 2017, 5:10am UTC](https://forum.dynamobim.com/t/changing-family-based-on-parameter-value/16147/8 "2017-11-04T05:10:46Z")

</div>

Righto, I knew I had seen something like this before.

I’ve just typed this out on my phone but it should be able to be adapted for your purpose @robertsb2010

Example:

X=input list of values  
a=family type 1 for values 0 to 100  
b=family type 2 for values 101 to 200  
c=family type 3 for values 201 to 300  
d=family type 4 for values 3011 to 400

The code block contents:

```
x>=0&&x<=100 ?
a:
x>=101&&x<=200 ?
b:
x>=201&&x<=300 ?
c:
x>=301&&x<=400 ?
d:
"Out of range";

```

The inspiration:

> [@If ( then , else) in dynamo](https://forum.dynamobim.com/t/if-then-else-in-dynamo/2556/6):
>
> Konrad, Michael, Many thanks. Managed to make it work! And the code block processes a list of 100+ values in seconds, when some of the monstrosities I’ve built out of nodes took ages! Just goes to show the inherent inefficiency of visual programming I guess. The end result looks like this: [Capture3] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Best Regards.

I’ll still see if my OOTB node solution idea works on Monday. 🙂

---

<div class="post-metadata">

**Author:** ![Ewan\_Opie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ewan_opie/32/77070_2.png) [@Ewan\_Opie](https://forum.dynamobim.com/u/Ewan_Opie)\
**Post date:** [November 6, 2017, 9:59pm UTC](https://forum.dynamobim.com/t/changing-family-based-on-parameter-value/16147/9 "2017-11-06T21:59:36Z")

</div>

Here is an example of the Code Block in action as well as my OOTB Node workflow.  
Please let me know if this solves your problem @robertsb2010 😀

Animation:  
 ![Multiple Inputs OOTB](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/b/9b6a905a863be326dc920812e498d627e5ae9272.gif)

Screengrab:

 ![OOTB and Code Multiple If Ranges](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/4/6495dba79c4cd86e52e2fd39588c0b923907c0b0.png)

---

<div class="post-metadata">

**Author:** ![robertsb2010](https://avatars.discourse-cdn.com/v4/letter/r/7c8e57/32.png) [@robertsb2010](https://forum.dynamobim.com/u/robertsb2010)\
**Post date:** [November 7, 2017, 1:58pm UTC](https://forum.dynamobim.com/t/changing-family-based-on-parameter-value/16147/10 "2017-11-07T13:58:16Z")

</div>

Wow, that code block is nice! I got it to work after toying with the code block contents a little bit. I was definitely confused by the code block workflow at first.

Also, I had to convert my list to ft3/sec as Dynamo doesn’t actually read cfm the way that Revit does. That wasn’t hard to do at all, just another step. Thanks for everyone’s replies!
