In a new Revit file, I created 6 parts from 2 wall objects with nested parts on purpose to illustrate my question.
I can see 6 different parts in my view, that’s what I want.
But in dynamo, if I want to select all my parts in the model, I get 9 items, including the parent parts.
- What could be the best way to select only visible parts ?
Then, I’d like to find the orientation of my parts, by getting their parent’s base line (wall).
As long as there are multiple level of child parts, I need to build a recursive code to extract a list containing only wall objects.
Existing node on SteamNodes package will only give first parent, so I get a mix of Wall and Part objects as a result.
I tried to construct something as a workaround, but it’s not recursive, so result’s reliability depends on how deep the structure will be.
I find that thread which gives me a little start. But I’m new with the Python for Revit Coding and I can’t find my way out of this.
import clr clr.AddReference('RevitAPI') from Autodesk.Revit.DB import * clr.AddReference("RevitNodes") import Revit clr.ImportExtensions(Revit.Elements) elements = UnwrapElement(IN) elementlist = list() def partParent(item): if item.Document.GetElement(item.HostElementId) == None: elementlist.append(item) else: partParent(item.Document.GetElement(item.HostElementId)) for elem in elements: partParent(elem) OUT = elementlist
- How can I modify that code to recursively extract only very first wall parent ?
Any help would be very much appreciated, thank you in advance.