How to set 'Formula' for parameters in family

Hi,

I need to set a value to ‘Formula’ field for some parameters in a family. I just tried using the script for setting ‘Value’, by replacing p.Definition.Name by p.Formula. But no luck. I am totally new to Python, though.

Can anyone please let me now how to do this.

Thanks

Vasu

Hi,

Anyone could help me on above query, please.

Thanks

Vasu

Hi @Vasu ,
I’m affraid Formulas can’t be set through API :

2 Likes

Hi @Mostafa_El_Ayoubi,

Thanks for responding. I tried the below script and it worked.

Thanks

Vasu

5 Likes

Nice! Sorry for the misleading info :grin: . Maybe it got you looking elsewhere at least…

1 Like

Erik, I have made good use of your nodes to set family parameters and it’s very handy in editing folders full of families, so Thank you very much for that. But I cannot figure out how to use the one that sets a formula.

In this example the parameter is a simple yes/no box, but I have tried it with numerical paramaters as well. Am I doing something wrong?

Tim

Hi to all, I’m trying to create a script to add some shared parameters to a family, and add a formula for each parameters.
I put all the info in a csv file, comma separated. Column value are:
(see attached img)


SP Name (name of the parameter)
SP Group (group of the shared parameter file)
Pgroup (type of the parameter eg: PG_IDENTITY_DATA)
Instance (Y/N if parameter is instance or not)
Formula (value of the formula I want to put for each parameter)

I’ve tryed to use the node "FamilyParameter.SetFormula) but I can’t find a way to put it in the right way…
I’m very new in coding with Dynamo so I don’t know very well how to do this…
Could anyone help me?
Many thanks.
SharedParam_to_family_SIMONE.dyn (46.7 KB) ![CSV_file|690x98]

1 Like

Hi my friends!
I Need the exact opposite,
I want to Get the parameters name + its current formula + its section ( Text, Data, Analysis etc) and export it into an excel or csv file.

Is it possivel? Thanks in advance

-same here

Did you solve the problem ?

Can you share me the solution how to add the formula.

I got stuck in the formula.

I missed an “i” in Revit.

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

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

param_name = IN[0]
param_formula = IN[1]

param_list = doc.FamilyManager.GetParameters()
names = [p.Definition.Name for p in param_list]
par1 = None
if param_name in names:
	par1 = param_list[names.index(param_name)]
if par1 != None:
	TransactionManager.Instance.EnsureInTransaction(doc)
	try:
		doc.FamilyManager.SetFormula(par1,'"' + param_formula + '"')
		OUT = 'Success'
	except:
		OUT = 'Failed'
	TransactionManager.Instance.TransactionTaskDone()
else:
	OUT = 'Failed'

I found out the code above is for one parameter only. It will not process a list of parameters. I believe I need to make a for loop to make it work, but the above code is a good starting point.