Change SharedParameter to FamilyParameter

Hi all,
long time reader first time poster!

I’m trying to find a way automate the conversion of a bunch of SharedParameters in a bunch of families to equivalent FamilyParameters. I would usually do this manually through the parameter properties of the family. (note i though i should also point out this script to be run while in the family editor, not a project)

After a brief look through the API I think this should be possible…
http://www.revitapidocs.com/2017.1/5eb146f4-968c-332e-b017-b9dd7b27274f.htm

So far I’ve managed to use a python node to get the properties I think i need from all the parameters in the family editor. I can then filter down to the shared parameters with a boolmask but am but i have no idea where to start in translating the syntax mentioned in the APIdocs into another python node (i have extremely limited knowledge of coding). Any help would be appreciated :slight_smile:

Thanks erfajo,
I have used the some of the orchid package before, great work by the way. However none of the parameter nodes have the ability to change the parameter property I’m after.

Theoretically i could make duplicate family parameters of the shared parameters with the orchid package, assign the same values from the shared parameters to the new family parameters but then i would also need get all instances where that parameter is used in the family(dimensions, materials, visibility, associated etc) and swap the shared parameter for the new family parameter.

I’m trying to avoid the extra steps by accessing the existing parameter properties directly. Which i think should be possible through the API.

Thanks will do.

After a few tries i managed to get something working.
Python node below for anyone else attempting the same thing.

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

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

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument
dataEnteringNode = IN

#unwrap all elements to use with API
elements = []
newlist = list()
namelist = list()
for i in IN[0]:
	elements.append(UnwrapElement(i))

# "Start" the transaction
TransactionManager.Instance.EnsureInTransaction(doc)

for i in elements:
	originalName = i.Definition.Name
	new = doc.FamilyManager.ReplaceParameter(i, i.Definition.Name + " - temp", 
i.Definition.ParameterGroup, i.IsInstance)
	doc.FamilyManager.RenameParameter(new, originalName)
	newlist.append(new)
	namelist.append(new.Definition.Name)
# "End" the transaction
TransactionManager.Instance.TransactionTaskDone()

OUT = (newlist, namelist)
2 Likes

@Josh it would be nice if you could post & format your code so we don’t have to retype it :wink:

no worries. I’ve added the code to the post above.

1 Like