List logic help needed

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
Parameter name
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:

The output looks like this:

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?


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:

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).

1 Like

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.

1 Like

@MVE1112 Combine.dyn (34.3 KB)

1 Like

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:

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.


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

@MVE1112 Try this:
Combine.dyn (30.8 KB)

@MVE1112 And if you don’t want the package dependency then try this Python approach.
Combine_Python.dyn (30.2 KB)

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):

OUT = lists
1 Like

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!!

1 Like