johnpierson / RhythmForDynamo

A collection of nodes for use in Dynamo with Revit.
BSD 3-Clause "New" or "Revised" License
108 stars 25 forks source link

FamilyInstances.RetrieveNestedComponent node is not working with linked Revit files #42

Closed ElieTRAD closed 2 years ago

ElieTRAD commented 2 years ago

Describe the bug any chance to fix the ʳʰʸᵗʰᵐ|FamilyInstances.RetrieveNestedComponents so it can get nested families out of families found in links?

Steps to Reproduce linkElement as output is not working.

FamilyInstances RetrieveNestedComponents

RhythmForDynamo/FamilyInstance.cs at 8381eb1a24d49f0e53282ab47938c469e4340af7 · johnpierson/RhythmForDynamo · GitHub

johnpierson commented 2 years ago

May I ask what that python script is?

ElieTRAD commented 2 years ago

Sure @johnpierson, here it is :

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
johnpierson commented 2 years ago

Cool cool. Next question, what is your downstream use-case for this?

ElieTRAD commented 2 years ago

No idea to be honest :), I was giving a hand to someone in the forum: https://forum.dynamobim.com/t/place-family-based-on-location-linked-nested-element/76907/24