How to set "NestedFamilyTypeReference" in Weld Symbol families?


Hi, Long time reader, first time poster!

I have several hundred Weld symbol annotations in our detail library. Of those, there are over a dozen different weld families. I am trying to use dynamo to change them all to one family we use as a standard. In order to do this I need to get the parameter values from the originals and then set the parameter values to the new family type otherwise they just default to the new families defaults.

The issue I am running into is that whenever I try to set the family parameter of any of the nested symbols I get an error and the family is deleted.

Is there a way to set a parameter values of type “NestedFamilyTypeReference” ?

I have tried strings, and actual parameter values for different welds, all do the same thing. Break :frowning:


Thanks in advance for any help. I am stuck

This might help you, There wasn’t a solution indicated but i assume that is because the owner forgot to do so given the last comment looked promising.

Thanks for the link and responding! :slight_smile: No dice unfortunately.
I feel like a cotton headed ninny muggins!

I have tried element Id, String, an index number because that’s how you handle the structural usage of beams. But nope, not here.


The selector is the family selection label. The families are generic annotations and there are 52 of them in the family to choose from. every single one of the weld families is all based on the same OTB weld with tweaks people and companies have made along the way.

NestedFamilyTypeReference Class (revitapidocs.com) seems to be the API element but being able to search for that is about the limit of my Python ability. :frowning:

Weld Symbol_Migrator Trouble shooting.dyn (36.5 KB)

Can you post an RVT with the requisite files and the DYN? Just checked your trust level so you should be able to post here, but if not you can utilize a 3rd party site like dropbox, onedrive, google drive, etc… :slight_smile:

1 Like

Welds.rvt (3.6 MB)
I just got a trust level upgrade! There is a drafting view with a few different weld families. The DYN is shared above.

1 Like

Hi,
here is an example with Python (compatible all py-engines)

set Nested Family

import clr
import sys
import System

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

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
uidoc = uiapp.ActiveUIDocument
app = uiapp.Application


def set_NestedParameter(paraToSet, lstParaIds, value_to_set):
	"""
	set parameter by list of NestedFamilyType and name of FamilyName
	"""
	for pId in lstParaIds:
		nestrefelem = doc.GetElement(pId)
		if value_to_set in nestrefelem.FamilyName:
			paraToSet.Set(pId)
			break

def toList(x):
	if isinstance(x, list):
		return x
	elif hasattr(x, "GetType") and x.GetType().GetInterface("IEnumerable") is not None:
		return x
	else :
		return [x]

elements = toList(UnwrapElement(IN[0]))
name_parameter = IN[1]
value_to_set = IN[2]

TransactionManager.Instance.EnsureInTransaction(doc)

for e in elements:
	#
	paraAnnot = e.LookupParameter(name_parameter)
	if paraAnnot is not None:
		currentSelectAnnot = paraAnnot.AsValueString()
		eTyp = doc.GetElement(e.GetTypeId())
		family = eTyp.Family 
		# get list of NestedFamilyType
		lstNestId = family.GetFamilyTypeParameterValues(paraAnnot.Id)
		# set Parmeter
		set_NestedParameter(paraAnnot, lstNestId, value_to_set)

TransactionManager.Instance.TransactionTaskDone()
		
OUT = elements
4 Likes

THAT DOES THE TRICK!!!

Thank you very much for your help!

1 Like