Family.SetParameterByName() in def Code Block not setting

I had to remake a few Code Blocks from recent versions to Revit 15 and noticed a few things I had to change as well as some things not always working as expected. I want to simply use the Family.SetParameterByName function in a code block as part of a larger definition.

Revit 2015
Code Block is using Imperative if that makes a difference

I’ve tried using the function both in my definition code block as well as in a simple one line code block:

Family.SetParameterByName(Inputting the Family Type of a Family Instance, “Parameter Name”, “Value to Set”);

Works in my recent versions of Revit/Dynamo. I get no errors in my current 2015 workspace and I confirm it works using the dynamo nodes Element.SetParameterByName. And yes, it is a Type parameter and a family type that is being fed in. Why is it not setting the parameter in the code block?

Show us your graph.

I did a quick test literally:

[Family Instance] ------- [FamilyInstance.Type] ------ [FamilyInstance.SetParameterByName(x,param,paramvalue);]

does not work.

However, I played around and used Element.SetParameterByName and it worked and furthermore if I did

it works.

So now if I have a list of Family Types familytypes how do I input for x in 0…List.Count(familytypes) familytypes[ x ] as an Element or FamilyType into the function FamilyInstance.SetParameterByName()? Since putting familytypes[ x ] directly does not work.

I’ve often wondered why some functions work no problem in code blocks and other seem to stop working. In any case, you’ll always get better responses if you can post a screen grab or something. It helps forum members understand what exact you are trying to do.

1 Like

It’s simply laid out but for you impaired:

whether I change the input to :var or :Element same results

Interesting method of get helping online: Calling the people who want to help you “impaired”. I’m out. A pro-tip might be to check people’s profiles before being smug online in the future. I’m out.



It’s called a joke. Just poking a little fun at our industry as we are largely visual. Appreciate you stopping by.

A poorly worded joke. Please refrain from such in the future. Let’s try and get back on topic though.

Why are you using imperative code in this situation? There is no need to use imperative code here as the built in lacing and list management will handle it easily.

Also, you may want to consider upgrading to a supported Revit version. 2015 has been unsupported for awhile now (~9 months).

Hey Jacob,

Referring back to my original statement, I am using Revit 2015 because I have to recreate some working definitions I have to this version for some projects that exist in 2015 unfortunately. Additionally, while it’s certainly possible to use the built in lacings/nodes, I wanted to get this to work because it works as part of a larger code block definition, making life a little easier without having to add additional nodes. The shown example again is just to narrow down the simple case of figuring out why it doesn’t work. Appreciate any help. Thank you.

Ah! The larger definition makes use of it. Got it now. I’ll try and take a look at it later, but for now can you try changing Family to Element and see if that results in a working function.

1 Like

Thanks @jacob.small I will also be doing some testing on my end and will let everyone know. Appreciate the help.