Linked Wall and Duct / pipe intersection point

Hello,

I am tring to export the intersection point between walls from linked wall and pipes / ducts etc in my model. I have found a script on Dynamo Forum which I have tweaked and it works when i run it in revitpythonshell if walls and ducts are all in same model (ie, not linked model)

from Autodesk.Revit.DB.Mechanical import *

linked_walls = FilteredElementCollector(doc).OfClass(Wall)
ducts = FilteredElementCollector(doc).OfClass(Duct)

lstIntersect = []
opt = Options()
opt.ComputeReferences = True
opt.IncludeNonVisibleObjects = True

lstIntersect = []

for duct in ducts:
    curvduct = duct.Location.Curve
    for wall in linked_walls:
        linkrefface = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Interior)
        intFace = wall.GetGeometryObjectFromReference(linkrefface[0])
        interArRef = clr.Reference[IntersectionResultArray]()
        if intFace.Intersect(curvduct, interArRef) == SetComparisonResult.Overlap:
        	pointIntersect = interArRef.Value[0].XYZPoint
        	print (pointIntersect)

my understanding is I need to transform the linked elements geometry for it it work with walls in the linked model.

I have found this post by searching Raybouncing in Pyrevit & unit conversion - #2 by Nicholas.Miles, but I can’t figure out how to transform wall geometry from linked model.
Could someone please help me by pointing me to teh right direction.
Thanks for your help in advance

1 Like

Hey @hoss53.
Here is a youtube video from Aussie Bim Guru that helped me to transform the linked model.
It is a Dynamo workflow,but he also shows the python code behind the transform node.

2 Likes

on this snippet which one is the linkedmodel?

linked_walls = FilteredElementCollector(doc).OfClass(Wall)
ducts = FilteredElementCollector(doc).OfClass(Duct)

you need to filter out that collection from a link document, not on active document, something like this:

all_links_view = FilteredElementCollector(doc, active_view.Id).OfClass(RevitLinkInstance).ToElements()

architectural_link = None

for link in all_links_view:
    link_name = link.Name
    parts_link = link_name.split(':')
    new_sel_link = parts_link[0]
    if "Architectural" in new_sel_link:
        architectural_link = link

link_model = architectural_link.GetLinkDocument()

all_rooms_in_link = FilteredElementCollector(link_model).OfCategory(BuiltInCategory.OST_Rooms).WhereElementIsNotElementType().ToElements()