makeParameterFamily.dyn (4.9 KB)
import clr
clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
# class for overwriting loaded families in the project
class FamOpt1(IFamilyLoadOptions):
def __init__(self): pass
def OnFamilyFound(self,familyInUse, overwriteParameterValues): return True
def OnSharedFamilyFound(self,familyInUse, source, overwriteParameterValues): return True
def changeParam(famdoc,name,make,result):
TransactionManager.Instance.EnsureInTransaction(famdoc)
try:
par_name = [a for a in famdoc.FamilyManager.Parameters if a.Definition.Name==name][0]
if make == True:
famdoc.FamilyManager.MakeType(par_name)
else:
famdoc.FamilyManager.MakeInstance(par_name)
result.append(True)
except Exception, e:
result.append([False,e])
TransactionManager.Instance.TransactionTaskDone()
doc = DocumentManager.Instance.CurrentDBDocument
result = []
if hasattr(IN[0], "__iter__") == True:
for i in IN[0]:
changeParam(doc,i,IN[1],result)
else:
changeParam(doc,IN[0],IN[1],result)
OUT = result
This works in a family .rfa file. Sorry, just got around to making it after seeing a thread about batch opening files and running a graph within each, thought it might help you out with what you are doing.