Looking for node to modify Parameter in *.rfa file

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.

I have opened your .dyn file and saw that there is no way to specify the file location. 2 inputs : Parameter Name and true/false (type/Instance, so no real way to specify which family you are changing.

Is it possible to add a file input on which the rest of the script should work? Just like the nodes in @erfajo his latest comment in this thread.

makeParameterFamily.dyn (7.5 KB)

Try this one. I don’t have time to test it right now as I am about to leave the office but I think it will work.

Sorry the script that had 2 inputs was for your request of wanting it to work inside a family file.

Also as a note:
Since it was done quickly, I didn’t set it up properly to be used with lists for the parameter names. I can fix it tomorrow for you.

No problem! I am already very grateful that you are taking the time to help me out. Only it was a misunderstanding. I am not using the script inside a revit family file. I want to use it for a batch of files … a folder with maybe 50+ *.rfa files.

If you have time, check out the nodes of Erfajo. I will try your script later today and give you feedback if it works :+1:

greetz