# List logic help needed

**URL:** <https://forum.dynamobim.com/t/list-logic-help-needed/61327>\
**Category:** Revit\
**Created:** [March 9, 2021, 9:07am UTC](https://forum.dynamobim.com/t/list-logic-help-needed/61327 "2021-03-09T09:07:12Z")\
**Posts on this page:** 8\
**Page:** 1

<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:** [March 9, 2021, 9:07am UTC](https://forum.dynamobim.com/t/list-logic-help-needed/61327/1 "2021-03-09T09:07:12Z")

</div>

Hello all,

I am in the process of creating a script that allows users to create a predefined PDF file name for sheets in Revit.

You can select a project or titleblock parameter, add a seperator and add another parameter and so on…

I am running in to a problem at the final part…

So basically, i receive a list that looks like this

Parameter name  
seperator  
Parameter name  
seperator  
Parameter name

I have two problems, one is that the parameter name can be either a project parameter or a titleblock parameter and i am not sure how to filter that to avoid empty lists…

The data shapes pop up looks like this:  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/9/e91fa9164aad45b7da7d24d3f165a4de4bd503e9.png)

The output looks like this:

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

So, there are two issues here…

The titleblock parameters get an empty list because they are trying to get a project parameter.

Second problem is a relatively easy list logic problem that i have no experience in…  
I need to swap out the “parameter names” for the parameter values in the correct order, while leaving the seperators in the correct spot…

Can anyone point me in the right direction?

---

<div class="post-metadata">

**Author:** ![Rickkrrd](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/rickkrrd/32/106127_2.png) [@Rickkrrd](https://forum.dynamobim.com/u/Rickkrrd)\
**Post date:** [March 9, 2021, 10:39am UTC](https://forum.dynamobim.com/t/list-logic-help-needed/61327/2 "2021-03-09T10:39:13Z")

</div>

Hi!

If you have 2 lists of strings, you can just use the `+` node to combine the 2 lists. If you find the Project Number, Sheet Number and Name of both the Project and the Titleblock, the output of non-found items is `""`. You will get a list A `["123456", "",""]` and list B `["","DO-03","Title"]`. Adding these will combine the strings, for example:  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/0/e0e0ce6148f93f20984bfa4a0303421edf09cdfe.png)

After this you can use `List.Insert` to add the seperators back in. You could also consider losing the whole `TakeEveryNthItem` node and feeding the `GetParameters` the original list from `List.Cycle`. Add the found items together and add to it a new list that has replaced the items at indexes [0,2,4] with `""` (so the separators are added to the empty spaces).

---

<div class="post-metadata">

**Author:** ![Bjorn\_Keulemans1](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/bjorn_keulemans1/32/54676_2.png) [@Bjorn\_Keulemans1](https://forum.dynamobim.com/u/Bjorn_Keulemans1)\
**Post date:** [March 9, 2021, 11:05am UTC](https://forum.dynamobim.com/t/list-logic-help-needed/61327/3 "2021-03-09T11:05:54Z")

</div>

Use Element.Parameters to read all available parameters from your ProjectInfo element. Then check the given parameter against that list to see if you should ask ProjectInfo for the value or the Sheet element.

For the other problem you can just use + in a code block to assemble the required string.

parameter1 + sep1 + parameter2 + sep2 + parameter3 and then connect the input from your form to the right inputs.

 ![project_info](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/7/67e44d88303305b9556d05334cc5d36d59de5ee9.png)

---

<div class="post-metadata">

**Author:** ![AmolShah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/amolshah/32/103244_2.png) [@AmolShah](https://forum.dynamobim.com/u/AmolShah)\
**Post date:** [March 9, 2021, 6:13pm UTC](https://forum.dynamobim.com/t/list-logic-help-needed/61327/4 "2021-03-09T18:13:52Z")

</div>

@Garbage_Collector [Combine.dyn](https://forum.dynamobim.com/uploads/short-url/6LpmDTj9ViiE4wPgG2Bfts55NEM.dyn) (34.3 KB)

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/7/07e4969a22081ad1af3834e3788b28fd0758f196.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:** [March 10, 2021, 8:31am UTC](https://forum.dynamobim.com/t/list-logic-help-needed/61327/5 "2021-03-10T08:31:16Z")

</div>

Wow thank you all for your help, that is very helpfull!

I tried your example AmolShah, It works almost perfectly!

I have one more problem to tackle with the list insert nodes unfortunately…  
The amount of parameters and seperators a user can add are variable, see below for an example:

 ![Capture2](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/1/8133ac83803083498d636f17bbcf303e32620974.png)

Do you have an idea how to make solve this issue? As you can see, the seperators after index 3 arent getting added to the list since i have not added an extra list insert node.

Edit:

I think list transpose should do the trick?  
Having some trouble with the levels now i believe…

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

---

<div class="post-metadata">

**Author:** ![AmolShah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/amolshah/32/103244_2.png) [@AmolShah](https://forum.dynamobim.com/u/AmolShah)\
**Post date:** [March 10, 2021, 3:48pm UTC](https://forum.dynamobim.com/t/list-logic-help-needed/61327/6 "2021-03-10T15:48:52Z")

</div>

@Garbage_Collector Try this:  
[Combine.dyn](https://forum.dynamobim.com/uploads/short-url/vqQw0FU24WmAvk7qq2pG65z0I2B.dyn) (30.8 KB)

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/6/46460b8f2433a8c9b91dd7e763004ee71d08ca84.png)

---

<div class="post-metadata">

**Author:** ![AmolShah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/amolshah/32/103244_2.png) [@AmolShah](https://forum.dynamobim.com/u/AmolShah)\
**Post date:** [March 10, 2021, 4:35pm UTC](https://forum.dynamobim.com/t/list-logic-help-needed/61327/7 "2021-03-10T16:35:39Z")

</div>

@Garbage_Collector And if you don’t want the package dependency then try this Python approach.  
[Combine\_Python.dyn](https://forum.dynamobim.com/uploads/short-url/tGzr5L6ZYQ142r0ZRk6VxFmuiaC.dyn) (30.2 KB)

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

```
toNestList = lambda x: x if any(isinstance(i, list) for i in x) else [x]

lists = toNestList(IN[0])
items = IN[1]
indices = IN[2]

for list in lists:
	for item,index in zip(items,indices):
		list.insert(index,item)

OUT = lists
```

---

<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:** [March 10, 2021, 7:48pm UTC](https://forum.dynamobim.com/t/list-logic-help-needed/61327/8 "2021-03-10T19:48:38Z")

</div>

That is amazing, I have a lot to learn…  
No clue what is going but it works exactly like i need it to, will try to figure out what is happening in your example haha:)

Thank you very much!!
