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
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.
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.
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…
Hi,
here is an example with Python (compatible all py-engines)
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