Hi,
here is an example with Python (compatible all py-engines)
import clr
import sys
import System
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
uidoc = uiapp.ActiveUIDocument
app = uiapp.Application
def set_NestedParameter(paraToSet, lstParaIds, value_to_set):
"""
set parameter by list of NestedFamilyType and name of FamilyName
"""
for pId in lstParaIds:
nestrefelem = doc.GetElement(pId)
if value_to_set in nestrefelem.FamilyName:
paraToSet.Set(pId)
break
def toList(x):
if isinstance(x, list):
return x
elif hasattr(x, "GetType") and x.GetType().GetInterface("IEnumerable") is not None:
return x
else :
return [x]
elements = toList(UnwrapElement(IN[0]))
name_parameter = IN[1]
value_to_set = IN[2]
TransactionManager.Instance.EnsureInTransaction(doc)
for e in elements:
#
paraAnnot = e.LookupParameter(name_parameter)
if paraAnnot is not None:
currentSelectAnnot = paraAnnot.AsValueString()
eTyp = doc.GetElement(e.GetTypeId())
family = eTyp.Family
# get list of NestedFamilyType
lstNestId = family.GetFamilyTypeParameterValues(paraAnnot.Id)
# set Parmeter
set_NestedParameter(paraAnnot, lstNestId, value_to_set)
TransactionManager.Instance.TransactionTaskDone()
OUT = elements