Set parameter of multiple family types in .RFA-file with python

I want to edit the parameter called “Dörrlittera” in the family editor. Just to get it to work i am trying to append the parameter with the string “AAA”.

If i understand this correctly there is 16 types of the parameter called “Dörrlittera”. As can be seen in the image.
I want to iterate through them and edit with Set().

But i can only change one of the types for some reason…
What am i doing wrong? The code seems to be working fine, except the “Set()” function.

import clr
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *

clr.AddReference(‘RevitServices’)
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

param_values =
types = doc.FamilyManager.Types
famMan = doc.FamilyManager

TransactionManager.Instance.EnsureInTransaction(doc)

familyTypesItor = famMan.Types.ForwardIterator()
familyTypesItor.Reset()
while (familyTypesItor.MoveNext()):
familyType = familyTypesItor.Current
familyParam = famMan.get_Parameter(IN[0])

param_values.append(familyType.AsString(familyParam))
		
famMan.Set(familyParam, IN[1] + familyType.AsString(familyParam))

TransactionManager.Instance.TransactionTaskDone()

OUT = param_values

hi @staffan.gustafssonTY

add this line:
famMan.CurrentType = familyType

before this line:

famMan.Set(familyParam, IN[1] + familyType.AsString(familyParam))

your code becomes:

import clr
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

param_values = list()
types = doc.FamilyManager.Types
famMan = doc.FamilyManager

TransactionManager.Instance.EnsureInTransaction(doc)

familyTypesItor = famMan.Types.ForwardIterator()
familyTypesItor.Reset()

while (familyTypesItor.MoveNext()):
    familyType = familyTypesItor.Current
    familyParam = famMan.get_Parameter(IN[0])
    param_values.append(familyType.AsString(familyParam))
    famMan.CurrentType = familyType
    famMan.Set(familyParam, IN[1] + familyType.AsString(familyParam))


TransactionManager.Instance.TransactionTaskDone()

OUT = param_values

-biboy

4 Likes

Hi blsalvio

Its working perfectly. You made my day :slight_smile:
I can finally continue, thank you.