I have this script and it gets the subcomponents of a family,
but i als want to add the host to the list so output needs to be host and a list with the subcomponents.
tried a few things but not getting what i need
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
items = UnwrapElement(IN[0])
def GetSubComponents(item):
# FamilyInstances
if hasattr(item, "GetSubComponentIds"):
return [item.Document.GetElement(x) for x in item.GetSubComponentIds()]
else: return []
if isinstance(IN[0], list): OUT = [GetSubComponents(x) for x in items]
else: OUT = GetSubComponents(items)
@Arno_De_Lange is it Ok like this?
if isinstance(IN[0], list): OUT = zip(items,[GetSubComponents(x) for x in items])
else: OUT = [items,GetSubComponents(items)]
1 Like
sorry i thought it worked⊠but i am now also getting the elements that donât have subfamilies in themâŠ
so if you select three elements and two have nested families in them, we only need those two
@Arno_De_Lange why donât you filter them out using OOTB nodes?
1 Like
Just add a condition to filter within your code.
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
items = UnwrapElement(IN[0])
def GetSubComponents(item):
# FamilyInstances
if hasattr(item, "GetSubComponentIds"):
return [item.Document.GetElement(x) for x in item.GetSubComponentIds()]
else: return []
result = []
for i in items:
# Get any SubComponents
sub = GetSubComponents(i)
if len(sub) > 0:
# If SubComponents found add a list item
result.append([i,[sub]])
else:
pass
OUT = result
3 Likes
Hi all,
I have the same problem.
My inputs are elements from a assembly, I want to retrieve the nested familys and add them to the assembly.
I donât have control over the count of the nested family, the family is sometime nested onces but sometime it is nested 2 or 3 times.
How can I deal with this?
@jw.vanasselt try the Family.GetNested
node from the Orchid package, it will fetch all nested families within project families, most probably you are targetting the Shared nested families, so you can filter these out using the Family Properties
node from the GeniusLoci package, with some list structuring I think you can get a list of the parent and nested families.
2 Likes
The orchid need a family document, I found this node: 
this one does the trick
1 Like
@jw.vanasselt check this if it works for you:
get Nested(deep).dyn (30.8 KB)
1 Like
Thanks! Thatâs really nice 
1 Like