Set parameter by name, using API

Hi,
how can I set a parameter by his name using the Revit API? I actually want to modify the value to one of the parameter of my FamilyType.

(I try to code exactly what the SetParameterByName note does)

Thanks!

Hi,

This was already exposed in the forum :

import clr

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
doc = DocumentManager.Instance.CurrentDBDocument


elements=IN[0]
parameter_names = IN[1]
values = IN[2]

for e, v in zip(elements, values):
	e.SetParameterByName(parameter_names,v)
#Assign your output to the OUT variable.
OUT = elements

4 Likes

I’ve tried this one, but ‘elements’ for me are FamilyType and the error says that FamilySymbol (my family type) doesn’t have the argument SetParameterByName

*attribute

SetParameter works with elements :

If you want to SetParameter inside a family, you can use the node from Orchid Package.
Family%20SetParameter

You need to post a snippet of your code so we can investigate where the issue is coming from.

We cannot do that with your description only.

Maybe this?

|Public method|ChangeTypeId(ElementId)|Changes the type of the element.

(Inherited from Element .)

If not it might help you identify an alternative solution…

http://www.revitapidocs.com/2018/f4f2420f-bba6-dac2-9b93-4e55a58d1375.htm

Hope that’s useful…

Mark

@YRioux
It is a bit unclear if you are working inside a project or a family. as @Alban_de_Chasteigner describes, you can use my nodes for family issues (the Orchid package) and if you are inside a project then you can use the OOTB nodes.
You can call this inside code as @Alban_de_Chasteigner show using the Dynamo API and you can also call it by using my assembly, however, mine is not documented for this purpose.’’
as @Mark.Ackerley demonstrates use the webpage for the Revit API if you want to code it the real way :slight_smile: