Associate family parameter in a family

I actually came across the need for this today for linking a Generic Annotation to a Titleblock for a complicated Key Plan. We’ll need to use Python to do it, and I’m thinking this is the API method: http://www.revitapidocs.com/2018/a047ea58-0351-b419-d856-85ed23734ee8.htm I’m not sure, though, if this method only works for element parameters in the family i.e. an extrusion’s “Visible” parameter

In any case, I have hit a wall with my test case and get the warnings “TypeError: expected Parameter, got Parameter” when feeding my Python script an Autodesk.Revit.DB.FamilyParameter element, and “TypeError: expected Parameter, got UnknownElement” when feeding it a ParameterElement :thinking:

I know the first error I’m getting is because I’m giving it the wrong type of “Parameter” (either Dynamo type or Revit type), and the second error makes me think Dynamo doesn’t recognize Family Parameter elements because thats typically what “UnknownElement” means, but I’m not sure how to get it sorted.

Here is the Python script I started:

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

elemParam = IN[0]
famParam = IN[1]


TransactionManager.Instance.EnsureInTransaction(doc)

doc.FamilyManager.AssociateElementParameterToFamilyParameter(elemParam, famParam)
	
TransactionManager.Instance.TransactionTaskDone()

OUT = elemParam

Hopefully someone else might know more to completing this (perhaps @erfajo if he is not too busy :slight_smile: )

2 Likes