# How to create a loop in Dynamo

**URL:** <https://forum.dynamobim.com/t/how-to-create-a-loop-in-dynamo/83495>\
**Category:** Uncategorized\
**Created:** [November 25, 2022, 12:31pm UTC](https://forum.dynamobim.com/t/how-to-create-a-loop-in-dynamo/83495 "2022-11-25T12:31:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luffy11](https://avatars.discourse-cdn.com/v4/letter/l/919ad9/32.png) [@Luffy11](https://forum.dynamobim.com/u/Luffy11)\
**Post date:** [November 25, 2022, 12:31pm UTC](https://forum.dynamobim.com/t/how-to-create-a-loop-in-dynamo/83495/1 "2022-11-25T12:31:51Z")

</div>

Hello everyone, I have multiple elements connect to each other. At the beginning, they have the same parameter value but when coordinating, the modelers may delete elements and draw new ones so they will not have value anymore. For that reason, I want to create a Dynamo script that can set value for the empty ones. My idea is find the elements that don’t have value but connect to the elements that have and set value from them. I did it already but I need to put it into a loop to solve for all cases. So is it possible to create a loop by using node in Dynamo? Because I don’t know any programming language. The image below will explain my idea (the green rectangles represent for elements that have value in a parameter and the red rectangles are the elements that don’t have value). Also, I’ve attached the dyn file, please take a look and advise if any. I’ll be appreciated.  
[Home.dyn](https://forum.dynamobim.com/uploads/short-url/6zd34o4BPjxi4DmRGYvqMz6CBy8.dyn) (49.6 KB)

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/0/e097b933b4ce7903cd965dd1040571e5444a1c06.png)  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/3/d3f7b09d6cf310a9b9066b5bfc0099f4a3d86059.jpeg)

---

<div class="post-metadata">

**Author:** ![jw.vanasselt](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jw.vanasselt/32/133533_2.png) [@jw.vanasselt](https://forum.dynamobim.com/u/jw.vanasselt)\
**Post date:** [November 25, 2022, 1:07pm UTC](https://forum.dynamobim.com/t/how-to-create-a-loop-in-dynamo/83495/2 "2022-11-25T13:07:14Z")

</div>

Hi @Luffy11 ,

You can use the MEPover package for that.  
Try this:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/f/9ff9da7a1643cf025789a7a46b743bbf781476af.png)

---

<div class="post-metadata">

**Author:** ![Luffy11](https://avatars.discourse-cdn.com/v4/letter/l/919ad9/32.png) [@Luffy11](https://forum.dynamobim.com/u/Luffy11)\
**Post date:** [November 25, 2022, 1:46pm UTC](https://forum.dynamobim.com/t/how-to-create-a-loop-in-dynamo/83495/3 "2022-11-25T13:46:11Z")

</div>

Thank you for your advice. Yes, I know this node but didn’t use it because if this line connects to multiple line ducts which have different values, how can we know the empty ones belong to which line?

---

<div class="post-metadata">

**Author:** ![jw.vanasselt](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jw.vanasselt/32/133533_2.png) [@jw.vanasselt](https://forum.dynamobim.com/u/jw.vanasselt)\
**Post date:** [November 25, 2022, 2:23pm UTC](https://forum.dynamobim.com/t/how-to-create-a-loop-in-dynamo/83495/4 "2022-11-25T14:23:55Z")

</div>

Maybe the connector node can help you?  
When you retrieve the connectors you have always 2 connectors (in this case)

Than you can group the elements by the connector

---

<div class="post-metadata">

**Author:** ![Luffy11](https://avatars.discourse-cdn.com/v4/letter/l/919ad9/32.png) [@Luffy11](https://forum.dynamobim.com/u/Luffy11)\
**Post date:** [November 25, 2022, 2:43pm UTC](https://forum.dynamobim.com/t/how-to-create-a-loop-in-dynamo/83495/5 "2022-11-25T14:43:03Z")

</div>

Oh yeah, that’s a good point. Thanks a lot for your help. I will try it.
