Importing plumbing fixture parameters from Excel to Revit

I am very new to Dynamo, and don’t have a lot of programing background.
I have been working on two dynamo scripts to modify parameters of Plumbing Fixtures in Revit. The first script exports all of my plumbing fixtures and their parameters into Excel. This seems to be working well.


I am running into problems when I try to get the edited parameters back into Revit. I seem to be dying at the List.GetItemAtIndex node. Warning: List.GetItemAtIndex operation failed. Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

The Element.SetParameterByName is also getting the error: Warning: Internal error, please report: Dereferencing a non-pointer. I assume that it is because it is being given a list full of null values.

Right now I am just trying to get a single parameter to import before I add additional parameters from the excel file. Any suggestions would be greatly appreciated.

Hi @jacobs and welcome, try to sort your elements using the node List.SortByKey

Would the key for List.SortByKey be the “Mark”. ?

I’d suggest exporting the Element Id or GUID of the fixtures in addition to their mark, then use that to get the elements you need in the second script (Element by Id is available in 2021+ and lots of custom packages and can be called in design script).

1 Like

@GavinCrump I was hoping to avoid using 2021, and Ideally would be in 2018, but I might have to look at it.

with a little more adjusting I have the script making it until the last node. any recommendations on testing what parameters a family has if it is giving you problems? a lot of the tutorials I am finding for Revit to Excel and back are dealing with a single family, not all of the families in that category.

thanks again.

So I think I have found the problem. I am calling All Elements of Category, and that returns FamilyInstances. I need to filter that selection to get the FamilyType? The parameters I am trying to modify are Type parameters. I think that is why my list keeps giving me null values. I don’t understand why my export file works if that is the case, but I will add that to the list of many things I don’t know.

After struggling to get anything out of this script I have finally made some progress. I have one script that looks at the plumbing fixtures in a project, and exports to excel the following parameters:

  • Mark
  • Level
  • Type
  • EQUIPMENT NUMBER
  • FIXTURE
  • PF TRAP
  • PF WASTE
  • PF VENT
  • PF COLD WATER
  • PF HOT WATER
  • MIXING VALVE?
  • MAX OUTLET TEMP
  • REMARKS
  • WFU
  • HWFU
  • Combined Water FU
  • CWFU

This part seems to work well.

Getting any of those values back out of excel and into Revit was a bit of a struggle, but I have some of it working.
• Mark (I don’t see a situation where I would be changing this, but it is working)
• Level (not working, but I am not sure it is a value I would ever need to change for the purpose of the script) Element.SetParameterByName error: Warning: Element.SetParameterByName operation failed. The parameter’s storage type is not a string.
• Type (not working, but I am not sure it is a value I would ever need to change for the purpose of the script) Element.SetParameterByName error: Warning: Element.SetParameterByName operation failed. The parameter’s storage type is not a string.
• EQUIPMENT NUMBER (working)
• FIXTURE (working)

These next parameters are arguably working, but have some issues.
These lists should have some null values, but my hack to get around them was to convert any null value to a 0. In a lot of my cases this is an acceptable solution, but I would prefer to keep the null values if I knew how.
Also, I am using a String.ToNumber node that is turning orange, but it seems to be working.
• PF TRAP (working with 0 for null, and String.ToNumber error)
• PF WASTE (working with 0 for null, and String.ToNumber error)
• PF VENT (working with 0 for null, and String.ToNumber error)
• PF COLD WATER (working with 0 for null, and String.ToNumber error)
• PF HOT WATER (working with 0 for null, and String.ToNumber error)
• MIXING VALVE? (working with 0 for null, and String.ToNumber error)
• MAX OUTLET TEMP (working, but has some formatting issues I need to resolve, and with 0 for null, and String.ToNumber error)
• REMARKS (working)
• WFU (this is an item I can see value in being able to edit, so I would like to resolve this issue. Warning: Element.SetParameterByName operation failed. The parameter is read-only.)
• HWFU (this is an item I can see value in being able to edit, so I would like to resolve this issue. Warning: Element.SetParameterByName operation failed. The parameter is read-only.)
• Combined Water FU (this might not be a type parameter like the others, so I have some testing to figure this one out. Warning: Element.SetParameterByName operation failed. No parameter found by that name.)
• CWFU (working with 0 for null, and String.ToNumber error)