Edit Formula Value in Project Environment for Multiple Families at Once


I have seen several posts on the forum solving the issue of setting formula values inside Revit Families using python.

We use quite a bit of manufacturers models especially when it comes to plumbing fixtures. The majority of these families have information in lowercase or CamelCase. We need everything in UPPERCASE.

I wrote a script that will extract the parameter values change them to uppercase and set the value back to the parameter.

Where I am running into trouble is with families that have manufacturer information written in them.


Is there a way within the project environment to batch change the values of loaded families formulas blank??

The example I show only has 3, but we have dozens of projects with more complicated schedules having the same issues.


See this post here :slight_smile:

The DanEDU Dynamo nodes should do just what you’re looking for. I’m nearly certain the set formula’s node should handle inputting a null value.


Thanks for the heads up on this package!

While this node set does allow me to get to the formula of the family it brings up 2 more questions.


This doesn’t allow you to edit the family from the project environment. This is more of a workflow concern, since i could save the families out to a folder and reload them once the formula is updated.

I could also not be understanding how to pass families inside the current document into the DanEDU.FamilyDocument.SetFormulaByName Node…


This one is the real issue, (fingers crossed there is a method for this)

When i open a family and simply delete the formula, what is left in the value field is what was written as the formula

If i try to input an empty string value what i get is ("") as the new formula.

it does that if i use code block or script node…seems inputting a “blank” string value for this is not the proper method


This may help / is at least good to look at.


Check the first image in the link I shared above - the package has a “Load Into Project” node, it appears this workflow should work from the project environment and background opens/modifies/closes the family documents, then reloads it into the current document

With the workflow I shared above, you wouldn’t be pulling the family documents from inside the current document, rather, plugging in the file contents of the directory where all the families are located into the Document.BackgroundOpen node

Try inputting a code block that says null with no quotes (not a string) and see if that works :slight_smile:

(the link @Steven shared is pretty much identical to what I linked above, there is a .dyn file attached)


Scratch this part that I said above:

You can obtain the loaded family documents via the DocumentUtilities.GetFamilyDocument node from the Beaker package:


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
from Autodesk.Revit.DB import*

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:
		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')
		log = 'An error occurred! Please veryfy setting'
		#only for testing
		#log.append('An error occurred! Please veryfy setting')

#output assigned the OUT variable
OUT = docs, log

This works on my end:

Create Parameters in a Revit Family

Hi @awilliams,

First of all, thanks for the edited python code :+1:
This workflow was also the solution for the below topic (as variation on the topic you mentioned in your first answer). https://forum.dynamobim.com/t/different-input-for-document-backgroundopen-node/15623/6

@William_Ruffenach Don’t forget to add the “DocumentUtilities.CloseDocument” (also Beaker) at the end to close the documents that were loaded in memory.

Kind regards,


nice edition of my code…

I dont know why I did change it to a string, I can see that the node “FamilyDocument.SetParameterByName” is taking the input in the “correct” way, so I must have forgotten to update the code in the “FamilyDocument.SetFormulaByName” node.

thanks for pointing this out :slight_smile:

The DanEDU Dynamo package is updated now…


Hi @William_Ruffenach,

This doesn’t allow you to edit the family from the project environment. This is more of a workflow concern, since i could save the families out to a folder and reload them once the formula is updated.

you cant edit formulas in project mode, that is not doable in revit at all. The only way is to open the family and edit the formula.

thats why I made the nodes for families and as @awilliams (and @MJB-online) describes, you must use a method to open and close the families. I use @john_pierson Rythm nodes since they do the job excellent (Beaker nodes is also @john_pierson).