Associate a Global Parameter to parameters of multiple Family Types

Hello Everyone,

I am trying to connect a Global Parameter to multiple Family Types using the method below. My output gives “Fail”. I don’t understand why it doesn’t work.

import clr

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

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

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

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

list = UnwrapElement(IN[0])
global_parameter = (IN[1])
parameter_list = []

TransactionManager.Instance.EnsureInTransaction(doc)

for family_types in list:
	type_parameters = family_types.Parameters

	for parameters in type_parameters:
		if parameters.Definition.Name == "buitenblad":
			parameter_list.append(parameters)
		
			for x in parameter_list:
				try:
					x.AssociateWithGlobalParameter(ElementId(global_parameter.Id))	
					out = "Success"
				except:
					out = "Fail"			

TransactionManager.Instance.TransactionTaskDone()

OUT = out

Just a guess, but it may be that you’ve already associated the family parameter with the global parameter. Are you providing only a single FamilyType from each Family? Parameter mapping is for all types within a family, so if you’re providing multiple types from the same family, then the parameter will already be mapped after the first type. Also, your loop is set so that you append a valid parameter to your list but then run through every item in that list every time you add to it. This means you’re already being redundant with parameter mapping just based on your list manipulation.

Other than that, have you checked all the standard requirements? Parameters are of the same type? None are being controlled by formulas or otherwise read-only?

I’d also suggest rewriting your python to include a list output so you can see the result of each family type. Right now you only get the result of the last family type since out is being overwritten in each loop until the loop ends. This would also be a good way to change how you handle your redundant list.