How to Element.SetParameterByName if there are two identical name of parameters?

Dear Folks,

I have a problem on Dynamo and need suggestions.
My current model has more than 200+ of CurtainSystem.
I need to set the parameter Offset on vertical curtain grid (Grid 1).
How can I access that parameter since there is another Offset parameter with the same name for Grid 2?
Please see my problem in the attached picture.

Your idea are welcome.

1 Like

Hi Kahn,

Since, you’re trying to access the parameter (Offset of grid 1) which is first on the list of instance parameter (Placed before Offset of Grid 2), the Element.SetParameterByName will automatically access the first parameter which comes first on instance parameter list. So, your needs in this case is sorted out (I’ve tried this out). But, anyways if you want to access Offset of Grid 2, the easiest way to do is to change the Parameter name (at least offset rather than Offset). Else, you might’ve to get into python if I’m not wrong.

Thanks,
Surya. B

Hi Surya,

Thanks for your guidance.
However, see my attached picture above, it automatically access to the second parameter, not the first one which I want.

Please notice that the value 200 assign to the second parameter.

hi @kahn.cad

check this out: set_parameter_value_by_name_and_pg_group.dyn (9.1 KB)

the script:

the result:
2

python code:

import clr

clr.AddReference("RevitNodes")
import Revit


isElement = False
elements = list()
values = list()

if isinstance(IN[0], list):
	elements = IN[0]
	values = IN[3]
else:
	isElement = True
	elements.append(IN[0])
	values.append(IN[3])
	
	

for e, v in zip(elements, values):
	for p in e.Parameters:
		if p.Name == IN[1] and p.Group == IN[2]:
			Revit.Elements.Parameter.SetValue(p, v)
			break
			
OUT = elements[0] if isElement else elements

good luck!

-biboy

1 Like

Hi @blsalvio,

Thanks for your genius solution.
Very appreciate your help.

Now, I can run my project successfully.

1 Like

Hi,
Sorry for that! Just saw the solution and happy for that.
Would love to contribute the solution I curated with dynamo nodes for anyone who’s looking at this for future reference.Same_Parameter_Name.dyn (30.3 KB)

2 Likes

Hi @Surya.bXAPUY,

Brilliant!

You have a solution!
Thanks for your kindness for helping me.
I just know that there is the node call “Parameter.SetValue”.

Before I post a question I try a lot of ways to solve but cannot.
However, two gentlemen @blsalvio and @Surya.bXAPUY can find beautiful solutions to me.

Your courtesy is much appreciated.

1 Like