Edit Formula Value in Project Environment for Multiple Families at Once

I just had a look at the Python code within the DanEDU.FamilyDocument.SetFormulaByName node, and it converts the values into strings so inputting a null value doesn’t seem to work. If you paste this into a Python script node, it will accept a null value (removed the quotes around values[idx] in line 39)

#Copyright(c) 2014-2017, DanEDU Dynamo
#Erik Falck Jørgensen, Technical University of Denmark (DTU)

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

clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

#log builder, only for testing
#log = []

#input assigned the IN variable
docs = IN[0]
params = IN[1]
values = IN[2]

#wrap input inside a list (if not a list)
if not isinstance(docs, list): docs = [docs]
if not isinstance(params, list): params = [params]
if not isinstance(values, list): values = [values]

#default document set to DocumentManager.Instance.CurrentDBDocument
if docs[0] == 'Current.Document':
	docs = [DocumentManager.Instance.CurrentDBDocument]
else: pass

#core data processing
for doc in docs:
	TransactionManager.Instance.EnsureInTransaction(doc)
	try:
		for idx, item in enumerate(params): 
			param = doc.FamilyManager.get_Parameter(item)
			doc.FamilyManager.SetFormula(param, values[idx])
			log = 'Formula set successfully'
			#only for testing
			#log.append('Formula set successfully')
	except:
		log = 'An error occurred! Please veryfy setting'
		#only for testing
		#log.append('An error occurred! Please veryfy setting')
	TransactionManager.Instance.ForceCloseTransaction()

#output assigned the OUT variable
OUT = docs, log

This works on my end:

4 Likes