Code Block / List indices must be numeric

Hello,
I’m new to this forum an I need your help:

I wrote a script (in Revit 2019 / Dynamo 1.x) to import several paramters from a excel-sheet to the MEP-Spaces. It worked fine so far until I change to Revit 2021 with a newer version of Dynamo (2.3).

Now I get the following error in the “Code Block”:

List indices must be numeric
*This error message indicates that you are trying to access an element in a list by using an index value that is not an integer (i.e., a whole number). *
*Starting with Dynamo 2.0, lists are collections of values where each value in the list can be accessed using only integer index values (index values range from 0 to list size minus 1). *
*Read more about differences between Dynamo 1.X and Dynamo 2.X (including how accessing elements in a list has changed) here. *
How to fix
Make sure the index value you use to access list elements is strictly an integer (e.g., 2 and not “2” or 2.0).

My script looks like that:


The numbers (e.g. 04.01.01…) are the room numbers and I want to find the matching room numbers of my excel-sheet and my MEP-Spaces.

Corresponding to the error message there was an change between the version 1.x and 2.x. Does anyone have a workaround for this issue? Is there a way to use the Code-Block with non-integers?

Best regard and many thanks in advance
Chris

Hi,

So in your code, I would expect to access value ‘04.01.01.015’ index ‘12’ of list ‘a’ … a[12] but you seem to be feeding the format a[04.01.01.015] is that the problem? The error is being thrown because 04.01.01.015 is not an integer but that isn’t quite what you wanted?

Cheers,

Mark

Hi Mark,

thanks for your reply.
I don’t exactly know what the problem is. I think the Code Block can’t handle non-integers.

I will try to find another solution.

Best regards

Hello @roth4QWW8 …could you share the dataset you working on ?

Hello sovitek, sure.
Unfortunately i can’t upload the file attached (new user :slight_smile:), so you can download it with the following link: https://www.dropbox.com/s/zd7hit6zrlqqp09/Luftmengen_MEP-Import_CR.dyn?dl=0

Thanks and best regards
Chris