Create a list with Python

Hi guys,
I created a script which is working but what I did is not very optimal. Indeed, the purpose of this script is to make an extraction about some doors parameters and create an Excel file with datas oragnized. In order to do that, I used List.Create node to organize my data into specific columns of my Excel file. So I linked certains inputs (item 1, 2, 4, 6, 9, 10…) to a Revit parameter which one is empty into my Revit model. I would like to replace this archaic process with something more efficient. Do you know how to create a list with a Python script? And create inputs for each parameter and organize datas according to Excel columns ?

Hi there,
To take data into excel you should have it organised in nested lists, that way it will show like an actual table and not a single flat list.
A list in python is simply created by using the square brackets with any items you want inside.
myList = [item1, item2, item3]
It would be helpful to understand better which data you are trying to organize and what format you want to achieve in the excel file.

My guess is the method you used to get the values from the doors could be more efficient. Try looking into cross product lacing on Element.GetParameterValueByName nodes as one method.

Thanks to both of you for your replies.
@bfreitas : i have a nested list, it’s not flatten, datas that I get are from different types (text, integer, number, length…) and come from Doors. The attached pic will show you the rest of the script for a better understanding. I tried to use myList but I didn’t succeed in it (into my PythonScript node I replaced item1, item2 by my inputs IN[0], IN[1]…).
@jacob.small : yes I know it’s not very efficient, unfortunately I have a lack of knowledge. However, I used Element.GetParameterValueByName nodes to get my datas parameters from my doors

Something like this makes your data collection already way more efficient.

Edit: you may have to set list level of the element input to @L1 or lacing to cross product :sweat_smile:

1 Like

it doesn’t help me much :sweat_smile:
first if I put every parameters into a code block they need to be ready for extraction into the Excel file, but as you can see on my script I modify some of the parameters (changing units or removing the beggining of the name).
Also, when I tried to obtain the same as you I can’t write the code like this into the code block. Dynamo doesn’t accept it. I don’t know why the syntax is correct for you and not for me…

Hi again,
That second image you posted made it a lot more clear to me!
I’m not sure why you were unable to create the list in python, but for your issue it is not really required.
To make lists in code blocks try the following syntax:
{item1, item2, item3}; or an empty list {};

For example you can replace getting the ‘commentaires’ from your doors by an empty list where you want to keep a blank column.

With the default tools I don’t think you can map your individual lists to specific columns or row, but you can still simplify a bit your dynamo and make it more manageable. See below example of Code Block to replace your List.Create node

image

Cheers

Looks like you’re using Dynamo 1.x, where as the other code block was for 2.x format. Swap [ for { and it should work.