Index if values matches

Hey community,

I am trying to add information from excel to revit using dynamo. However, I got stuck and could not figure out the way out.

Case: I am trying to look if object parameter “CCSSingleLevelID” matches data in column C, if it does the value from column A in the same row should be returned to the parameter “Duration”. The CCSSingleLevelID values are unique, there are no repetitves in both model and excel sheet.

I have tried to do it the following way. Where did I fail? It returns values to the incorrect object.

Thank you for the help!

Hey mate, I think you have runned into a similar issue I had short time ago, you want to compare two lists and find out the matching ones and assing a value according to it.

here is the post were my issue was solved, hope it can help:
(I will try to test it with your data, no promises I will achieve something, hopefully some veteran will do it shortly)

Thank you for the response, however, your issue was slightly different and I cannot work around it to help to solve mine. Thanks for the input anyway!

1 Like

The issue is with the code block:


There is no comparison there - you are just reassigning the data in list a at index i to be the value j.

I assume you’re trying to compare List K (your parameter values from the Revit model), to the values in List I (the excel data with data that starts with a [L]), and return the value of lost J (the excel data with no prefix) when they match.

  • Start by using an == node to do the test for List K and List I. Watch lacing as you will need to get a single true/false value for each element in the Revit parameter value list for every item in the excel data list.

  • Then using an index of node to find the index of the true value for each sublist.

  • Next use a Get item at index node to return the value of each sublist.

  • Lastly use the Element.SetParameterValueByName node to assign the values.

Beat to rest this detached as your data set looks pretty large.

Thanks for the reply. You understand my case correctly.

However, your methods seems plausible, but I am not really sure how to execute it, hopefully you can find time to present it.

Data set is not large yet, I intend to do this for way larger model, therefore the most optimal solution would be appreciated.

Try this

ExcelColumn1 = IN[0]
RevitValue = IN[1]
ExcelColumn2 = IN[2]

t1 = []
for rc in RevitValue:
	for idx, ec1 in enumerate(ExcelColumn1):
		if rc == ec1:

OUT = t1

…or this

ExcelColumn1 = IN[0]
RevitValue = IN[1]
ExcelColumn2 = IN[2]

t1 = []
for rc in RevitValue:
	for ec1, ec2 in zip(ExcelColumn1,ExcelColumn2):
		if rc == ec1:

OUT = t1
1 Like

Thank you!

I definitely need to learn Python, which seems can solve anything with a good understanding.

Did you try to wire your Watch node to the “a[k];” output? It should return the correct result :smirk:
Here is also a example for anyone interested.


@Yna_Db You are totally correct. I was following exactly the same thread from the beginning, but totally missed that the output is from a[i]=j…

It means that the thought was correct, just the execution was failed in the last step.

@Yna_Db your solution is way easier than @erfajo, but anyway both solutions work!

Thanks everyone!

This post has helped me immensely so thank you to all contributors in advance. One additional question, Is it possible to expand on this idea and have multiple values from excel report back to different element fields in Revit? If so, what would that look like? See my markup of a previously posted image for further clarification.

1 Like