Element.SetParameterByName with Excel File

Hello I am a new poster.

I’m having a lot of trouble trying to feed in a list of parameter names, values, and elements into the Element.SetParameterByName. It keeps giving me the error “Dereferencing a nonpointer”. I’ve gotten rid of the null values, but I still have this error.

To provide some context, I’m trying to import an large excel file wilth about 63+ headers. I’m using a specific header to identify and match it up with the Revit parameter list. (The goal is to fill out the some of the missing information in Revit.) However, in the excel file, there are some portions that aren’t filled in, so I filtered those out. But once I filter those out, the Revit parameter name list doesn’t match up with the Excel file (in terms of data type and such).
Is there a way around this? I have a theory that the data types aren’t matching up, (and also at times one list goes out of bounds (seg faults) that that I get the deferencing error).

So is there a way to use that identifying parameter from the excel file, and somehow automate the matching of the parameter names and/or values with the excel data? There’s A LOT of families and I don’t want to separately code data entries for each family.

Can you show us what your graph looks like? You should be able to keep empty parameters, but you may need to convert them to nulls.

Here’s where I’m inputting the parameter name and value information from Revit (I’m using only one family instance to test it out)

These are the values I’m inputting from excel. I’m grabbing only one family (row) from excel. I’m getting rid of a few items because they aren’t needed in the revit family.

Here’s what’s inside the second python script (I’m just getting rid of null values)

As you can see, the parameter list from Revit doesn’t really match up with the excel file. I can’t really control it since it’s a huge excel file that was given to me by someone else. So there will be different places where there’s no information filled out. I was thinking that I can set up some type of system to assign parameter names to the excel data, so that it knows which parameters to match it up with Revit, however, I’m not sure if Dynamo is even capable of that.

Your first issue is that you don’t have any Revit elements to assign values to. It’s hard to tell what else might be causing issues until this gets fixed. You’ll likely have to compare your Revit elements to the elements you have listed in Excel.

Could you show me an example on how to do that? (Sorry, I’m pretty new to Dynamo and Revit)!

Also, what I want to do with the Revit family that I got is to fill in some of the missing data that the Excel file would have, if that makes sense?
Would the process still be the same if I’m trying to enter in data for an existing Revit family?

Thanks!

The only thing that would make a difference is if you’re modifying a family in a project vs a family in the family editor. Within a project it’s all basically the same.

What does your excel data look like? It sounds like these are for instances so there should be some kind of identification (mark, Id, location, etc.) That’s what you’ll need to use to get the correct element in Revit.

Would I still be using a Element.SetParameterByName node or a completely different node when doing either? Also, if it’s still Element.SetParameterByName, could you show me an example? I’ve looked at other people’s work, and it looked to me that they were just passing in Revit parameter values and names that had already been set for the element and parameterName, respectively.

My identification variable is Model, and they are for instances.

You would use Element.SetParameterByName for an element in the project environment. It could be different depending on what you’re doing in the family environment. Element.SetParameterByName requires an element object input. You’re giving it strings. There are tons of posts on the forum dealing with importing Excel data into Revit elements. Try searching for some of those to get an idea for what you need to do. You’ll probably have to get all the elements of a particular category and compare them to the Model values you have in excel.