Adding parameters to a family

Hi,

There is a library of 1500 revit families i need to update. Basically i need to add 3 parameters from a given shared parameters file to each .rfa file.
After looking around this forum and google about this, I have arrived to this solution :

  1. Create a dynamo that work for one family
  2. Use revit Batch processor to : Open a .rfa file, run this dynamo script, Close the file.

So my dynamo script just basically need to turn shared parameters into family parameters.

Is there a node Out Of The Box that does this ? I have been experimenting with “CreateProjectParameter” and CreateSharedParameter" but they both seem to do the same thing : creating a shared parameter.

Thanks in advance for the help.

2 Likes

Hi there,

You could use Orchid Package to do that.

Cheers

Manel

I believe that at this time the only way to create parameter via the API is to create a new shared parameter.

Jacob, if I’m not mistaken, that thread regards creating project parameters programmatically only. I think what the op is after, is adding shared parameters from an existing shared parameter file, which can be done, but I do not think any of the nodes in the major packages support this, at the moment.

I created a workflow for this specifically, to batch add two specific shared parameters, from the IFC shared parameter file.

Python Script 1:

import clr
import System

#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

groups = System.Enum.GetValues(BuiltInParameterGroup)

res = []

for i in groups:
	res.append(i)

OUT = res

Python Script 2:

import clr

#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

#Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

#Reference the active Document and application
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

#Start scripting here:

defGroupName = IN[0]

spf = app.OpenSharedParameterFile()

definitionGroup = None
spfGroups = spf.Groups
definitionGroup = spfGroups.get_Item(defGroupName)
	

OUT = definitionGroup

Python script 3:

import clr

#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

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

#Reference the active Document and application
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

#Start scripting here:
pGroup = UnwrapElement(IN[0])
PDefinitionGroup = UnwrapElement(IN[1])
pNameLst = IN[2]

extDef = []

for i in pNameLst:
	try:
		extDef.append(PDefinitionGroup.Definitions.get_Item(i))
	except:
		extDef.append('Failed to append Def')

fm = doc.FamilyManager

output = []

TransactionManager.Instance.EnsureInTransaction(doc)
for i in extDef:	
	try:
		fm.AddParameter(i, pGroup, False)
		output.append('Parameter was successfully created')
		
	except:
		output.append('Operation Failed')

TransactionManager.Instance.TransactionTaskDone()

OUT = output

Params created:

And if you compare the GUIDS of the params, they will match :-).

The above graf is run in a Family Document, but it can of cause also be adjusted for batch creation:

Edit: Oh, and I didn’t get around to implement propper exception handling yet, but I might get the time at some point :slight_smile:

3 Likes

Hi @MartinSpence,

Do you think that the same workflow can be done to remove the shared parameters already present in the family?

Thanks for your time.

Best regards,
Michele

Hi @michele.fiaschi,

I believe the process would be less complicated :slightly_smiling_face:.

Start a new thread, and show what you’ve tried so far. I’ll supply an attempt if needed :+1:

Hi @MartinSpence,

I am convinced, especially for those unfamiliar with python like me. It would still be fantastic to be able to manage the addition of parameters and deletion without necessarily opening the family but perhaps selecting one or more specific files.
I open a new post, we feel there.

Thanks a lot and see you soon.

Best regards,
Michele

Hi @MartinSpence,

is there the possibility of managing the creation of the parameter as a type or instance?

Thank you very much and best regards,
Michele