Set associate parameter in Family

Hi all,
I found the node Parameter Associate in Orchid Package but it doesn’t work. Anyone can tell me what I am wrong? I appreciate for your advance.

i think your workflow is a bit wrong, its parameter, not parameter name. Hence you cant feed a string to it. Second, i dont think you can use document.current. you might need to use the family document that comes from the same package? i do not have dynamo access right now so thats my guess

1 Like

Thanks for your advance but when I review sample from @erfajo , he did the same, unfortunately, mine got the trouble.

Hi @erfajo,
Thanks for reply, sure I will try it, this node very useful for set materials.

Thanks Erik for spent time to me, actually, I was trying your node whole day today but it still doesn’t work, it is so weird. I need this node for set up material to all nested family and when I load family to project, I won’t miss any component without material anymore.

By the way, I found script from @awilliams, It work well with me.
I think if your package have node same this, can be collect the elements directly from family enviroment, will be better, but your package is awesome, keep it up.

Here is the code for someone got same problem:

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

clr.AddReference('RevitNodes')

import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

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

doc = DocumentManager.Instance.CurrentDBDocument


elements = IN[0]
epSearch = IN[1]
fpSearch = IN[2]

if not isinstance(elements, list):
	elements = [elements]
if not isinstance(epSearch, list):
	epSearch = [epSearch]
if not isinstance(fpSearch, list):
	fpSearch = [fpSearch]

for e in elements:
	e = UnwrapElement(e)
	elemParams = e.Parameters

	epNames = []
	fpNames = []
	elemAssoc = []
	famAssoc = []
	
	for ep in elemParams:
		epNames.append(ep.Definition.Name)
		
	epDict = dict(zip(epNames,elemParams))
	elemAssoc = [epDict.get(ep, "none") for ep in epSearch]
	
	famParams = doc.FamilyManager.Parameters
	
	for fp in famParams:
		fpNames.append(fp.Definition.Name)
		
	fpDict = dict(zip(fpNames,famParams))
	famAssoc = [fpDict.get(fp,"none") for fp in fpSearch]
	

	TransactionManager.Instance.EnsureInTransaction(doc)
	
	for i,j in zip(elemAssoc,famAssoc):
		try:
			doc.FamilyManager.AssociateElementParameterToFamilyParameter(i, j)
			error_report = "No errors"
			
		except:
			error_report = "can't assign parameter"
	TransactionManager.Instance.TransactionTaskDone()


OUT = elements,error_report

Hi @erfajo, that is exactly what I am wrong!, ha, now the node work like a charm. You should rename the input FamilyType to elements which made the confuse. Thanks a lot!