# Logical Operation - See Photo

**URL:** <https://forum.dynamobim.com/t/logical-operation-see-photo/21469>\
**Category:** Revit\
**Created:** [April 28, 2018, 8:45pm UTC](https://forum.dynamobim.com/t/logical-operation-see-photo/21469 "2018-04-28T20:45:40Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![kvusal](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@kvusal](https://forum.dynamobim.com/u/kvusal)\
**Post date:** [April 28, 2018, 8:45pm UTC](https://forum.dynamobim.com/t/logical-operation-see-photo/21469/1 "2018-04-28T20:45:40Z")

</div>

Dear Experts,  
How can I make script to automatically replace “unoccupied” with continues number 01,02,03 and etc. Please see screenshot.  
Please help.

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/1/e17322271283270487df13b0df58ecad589dd728.png)

---

<div class="post-metadata">

**Author:** ![Jonathan.Olesen](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jonathan.olesen/32/44242_2.png) [@Jonathan.Olesen](https://forum.dynamobim.com/u/Jonathan.Olesen)\
**Post date:** [April 28, 2018, 9:16pm UTC](https://forum.dynamobim.com/t/logical-operation-see-photo/21469/2 "2018-04-28T21:16:37Z")

</div>

Quite doable by a little python:

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

And if you need to have the “01” not the “1” this can be accomplished like so:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/6/46b6844b965786d41c788eb00d3e75089c8f3fdb.png)

---

<div class="post-metadata">

**Author:** ![Jonathan.Olesen](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jonathan.olesen/32/44242_2.png) [@Jonathan.Olesen](https://forum.dynamobim.com/u/Jonathan.Olesen)\
**Post date:** [April 28, 2018, 9:39pm UTC](https://forum.dynamobim.com/t/logical-operation-see-photo/21469/3 "2018-04-28T21:39:24Z")

</div>

```
import clr
lst = IN[0]
cond = IN[1]
num = 1
output = []
for x in lst:
	if x == cond:
		if len(str(num)) == 1:
			output.append('0'+str(num))
		else:
			output.append(str(num))
		num = num+1
	else:
		output.append(x)
OUT = output

```

And here is the code. 🙂

---

<div class="post-metadata">

**Author:** ![kvusal](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@kvusal](https://forum.dynamobim.com/u/kvusal)\
**Post date:** [April 29, 2018, 6:54am UTC](https://forum.dynamobim.com/t/logical-operation-see-photo/21469/4 "2018-04-29T06:54:36Z")

</div>

Dear Jonathan,  
Many thanks for your support. When my input list is at L3 level this script is not working. ☹  
What should I do?  
Please see photo:  
[Capture2.dyn](https://forum.dynamobim.com/uploads/short-url/y8GfDcmSmr4v7bDrFPqlhhmDXVg.dyn) (3.5 KB)

 ![Capture2](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/b/4beea1e1f83c23bca4b9bd493f4bd925f64847cb.png)

---

<div class="post-metadata">

**Author:** ![Jonathan.Olesen](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jonathan.olesen/32/44242_2.png) [@Jonathan.Olesen](https://forum.dynamobim.com/u/Jonathan.Olesen)\
**Post date:** [April 29, 2018, 7:29am UTC](https://forum.dynamobim.com/t/logical-operation-see-photo/21469/5 "2018-04-29T07:29:12Z")

</div>

If you make it a custom node and set the list level on the list-input it will work 🙂

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/1/b1cd0d8bd63fc63c4e97a6e34bbf88b831dfcba7.png)

---

<div class="post-metadata">

**Author:** ![kvusal](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@kvusal](https://forum.dynamobim.com/u/kvusal)\
**Post date:** [April 29, 2018, 7:38am UTC](https://forum.dynamobim.com/t/logical-operation-see-photo/21469/6 "2018-04-29T07:38:12Z")

</div>

Many thanks

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [April 29, 2018, 5:20pm UTC](https://forum.dynamobim.com/t/logical-operation-see-photo/21469/7 "2018-04-29T17:20:03Z")

</div>

@kvusal Using Design Script (ver 2.0)

 ![replace](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/0/500db955f8892ff7f99b29a26e14bf263a1fe4db.png)

```
def rep(a:var[])
{
	return = [Imperative]
	{
		b = 0;
		c = [];
		e = 1;
		for(d in a)
		{
			if(d == "unoccupied")
			{
				c[b] = String.PadLeft(e+"",2,"0");
				b = b+1;
				e = e + 1;
			}
			else
			{
				c[b] = d;
				b = b + 1;
			}
		}
		return c;
	}
};
```

---

<div class="post-metadata">

**Author:** ![Dimitar\_Venkov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dimitar_venkov/32/2068_2.png) [@Dimitar\_Venkov](https://forum.dynamobim.com/u/Dimitar_Venkov)\
**Post date:** [April 30, 2018, 4:49am UTC](https://forum.dynamobim.com/t/logical-operation-see-photo/21469/8 "2018-04-30T04:49:02Z")

</div>

If you want to avoid code, you could try the following:

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

---

<div class="post-metadata">

**Author:** ![Scott\_Crichton](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/scott_crichton/32/8876_2.png) [@Scott\_Crichton](https://forum.dynamobim.com/u/Scott_Crichton)\
**Post date:** [April 30, 2018, 6:34am UTC](https://forum.dynamobim.com/t/logical-operation-see-photo/21469/9 "2018-04-30T06:34:40Z")

</div>

You could also try…just need an Archilab node…

 ![Logic-Dynamo](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/3/f3534127d395c2f5e5774fd11f2192b7c7874ef4.png)

---

<div class="post-metadata">

**Author:** ![Jonathan.Olesen](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jonathan.olesen/32/44242_2.png) [@Jonathan.Olesen](https://forum.dynamobim.com/u/Jonathan.Olesen)\
**Post date:** [April 30, 2018, 7:25am UTC](https://forum.dynamobim.com/t/logical-operation-see-photo/21469/10 "2018-04-30T07:25:22Z")

</div>

@Scott_Crichton and @Dimitar_Venkov  
Very nice! I thought that it would be doable using just nodes, I’ve tweaked your graph a little to work with multiple lists and numbers above 9 🙂

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/5/c5a4250784cf805a3c4dbca981ea6b5a37e419f6.png)

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [April 30, 2018, 8:16am UTC](https://forum.dynamobim.com/t/logical-operation-see-photo/21469/11 "2018-04-30T08:16:52Z")

</div>

With only OOTB nodes 🙂 …

 ![replaceMultiple](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/f/dfb6bb04a8713fca51c4b7c6c268c4310aa0bc08.png)  
[replaceMultiple.dyn](https://forum.dynamobim.com/uploads/short-url/wLJ9Zparohp7AkjuUN68jDGEBL6.dyn) (29.9 KB) (ver 2.0)

---

<div class="post-metadata">

**Author:** ![Jonathan.Olesen](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jonathan.olesen/32/44242_2.png) [@Jonathan.Olesen](https://forum.dynamobim.com/u/Jonathan.Olesen)\
**Post date:** [April 30, 2018, 8:34am UTC](https://forum.dynamobim.com/t/logical-operation-see-photo/21469/12 "2018-04-30T08:34:42Z")

</div>

I think this thread quite nicely shows the beauty and power of both the forum and Dynamo as a tool 🙂  
The fact that for even a quite simple problem already 5 different possible solutions are offered!
