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.

1 Like

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.

1 Like

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

Script Delete Family Formula

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:


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).


Sorry to bring this up, am getting an error :

An error occured! Please verify setting

you did not say what the error was, so i tested and got this new error to me:"… expected Document got Document".

so i looked it up and maybe the solution is in this:

namely : doc = DocumentManager.Instance.CurrentDBDocument

hope that’s it

Hi I think in can read the documents, it’s the parameter and values that it cannot read/write or whatever…

anyway here is the error…
IN[0] - Document
IN[1] - params
IN[2] - values


I think I am using a concoction of the code you are using and code from other post, and reading and writing using setformula works for me as long as I am writing strings.
But the first thing that I noticed in the code that you are using is that it is missing the unwrapelement.
I know you said that you can read the doc, but per link below, it will cause you trouble at the end if you don’t unwrap it.
Give it a shot.

how to fix the “unwrap” thing? I have zero knowledge in phyton…

@Revit_Noob So i am not sure how to fix your code… i 've tried all i know with no results…
but if all you want is to add text value to a parameter, they you can use the code attached… the only catch here is that you have to load your family into some project, then run dynamo from within that project. so you cannot run it on the family itself.
if this works for you and you have a bunch of parameters to change, i can send you the code to load them from excel.
Revit_Noob.dyn (25.1 KB) Revit_Noob.pdf (107.6 KB)

1 Like

Hi, it worked!
Is it possible to filter the family via “prefix” and it will write to all the families?

Yes, you can.
In step 2, in the pdf that sent, you can put the prefix there instead of “family…add to”.
You will find this in the “string contains” node.
Just put any value that is unique to the families that you want to modify.

1 Like

if you need to modify a lot of parameters, you can put them in an excel csv file and let dynamo do the work.

1 Like

hi if you have time, can you give me an example with the excel thing?
not sure how to do that…