Automatic tags from excel

Dear fellow Dynamo users

We need some help in developing a script to assist our Revit teams in production.

Currently, we have a large project with multiple rooms, with each assigned a corresponding tag for room code, name, area and comment. These are all done manually based on and is time-consuming.

The idea (if possible) is to create a detailed excel file by encoders instead of Revit specialists, inputting a code, with corresponding room code, name, area and comment. Those in Revit would only need to tag the code and with a Dynamo script, read this code per room, search for the same code in the Excel, take the associated information, and tag this on the element.

Can this be done using Dynamo and Excel?

You can not tag directly from excel sheet I think … You might create an instance parameter to those rooms and feed it with the required tag value from excel then change tag family label to that parameter to be displayed instead of default one.

Hope it helps.

As @ingenieroahmad said, you won’t be able to get the data in Excel on the fly, but you can feed the room properties with an excel table.

thank you both for the quick replies @ingenieroahmad @M.Perez

we are actually non-engineering staff who are familiar with programming but not so much into Revit.

I might have used an incorrect term in explaining. What the goals is to take a room’s number (such as SB101), search for it in the excel file, retrieve the information corresponding to that number (which contains the room code, name and comments encoded in an excel file) and set them as the corresponding properties.


we are currently using the Element.GetParameterValueByName node but are still working on the script and setup, and have not gotten it to work yet.

t1_1.dyn (42.9 KB)
1.xlsx (8.5 KB)
Try this script on Dynamo 2.02 along with excel sheet, Sure you might change name of parameters as required or add new ones.

I hope it achieves your goals.

1 Like

thank you for the sample code… i was able to try it out

this is the first time I’ve used this node “SortByKey”. This error came up when I tried your test program and excel

this is actually the WIP version I have been trying before I saw your reply. It seems like we are on the same track and idea as I see similar logic. In my version I am also getting the same error message “internal error dereferencing a non-pointer”

error says : number of items not matching number of keys make sure that those items are equal.

1 Like

keys would mean the # of entries in the excel file right?

I modified it so just select one room temporarily, and edited the excel to only have one entry but the same error still pops up

You can use a “Watch” node to check how your input in “keys” and “list” look like. It may be a hierarchy problem, different levels in the inputs.

1 Like

I got it to work. Seems like clearing some cells in Excel resulted in them being “null” but there were still being recognized in Dynamo, hence an incorrect # to keys error

I tried it one when selecting a single room + having only one entry in the excel file (other than the title) it works perfectly now, thank you!

one problem that i notice however, is that if the # of entries does not match the # of selection (or the total number of elements) the program will result in an error and not run

could there be a work-around for this? for example, only a handful of elements need to be updated, but the excel file has the complete master list of everything

You could make use of Dictionaries and ValueAtKey (OOTB if I am not wrong) or Dictionary.ByKeysValues from Springs.

I faced one a similar problem and ended using Python. Could be another option.

I could not get the Dictionary to work. Was able to use the Dynamo in the Excel to Revit Families sorted via Excel Value thread

The entire script is working correctly and I see the outputs giving the desired values

But for some reason, the information is not being inputted into the Room Element
Room “SB103” should have the information:

  • B1_SS2_R009
  • test room 2
  • HSFP=3m


seems like the code is working but only for one entry (labeled in red)
the node ByParameterStringValue comes up will all 3 items in the list, but the next node SetParameterByName only considers the 1st one.

what is a good solution so that the other rooms (labeled in blue) are also considered by the SetParameterByName?

Sorry, I couldn’t answer before. I hope you could solve your problem.

In case you haven’t. I don’t get what are you trying with “To Disregard Title Item”. Both lists should have the same structure.

If you are trying to remove "number, "you should do it before feeding “ElementFilter.ByParameterStringValue”

thank you for the response

I already got a solution, shared in this thread here