Duct and linked Wall intersection

I have followed a youtube from Bimorph Here to create a graph the report the point the ducts clashing with walls.
I have used “Arch Link Model” from “C:\Program Files\Autodesk\Revit 2021\Samples” and placed all the ducts at 1500mm elevation.

It seems to work in some of the areas, but not everywhere. I have highlighted the area that it has worked in yellow and put red circles where it has not worked.
Not sure where I have gone wrong, any help will be appreciated. Thanks

Wall Duct Intersection.dyn (33.0 KB)


Hi @Hoss not sure but could these walls be curtain/ stacked walls ?

1 Like

Hello,
Wall are from a same type.
I have changed my graph like this and it is working fine now. Thanks

1 Like

I was wondering if there is a way to achive this using python script
tried to use this Finding intersections points between pipes and walls - #12 by c.poupin, but its not working

Hi,
is there an error or the result is wrong?

I have changed the code as follow, since I have the wall in the linked model and ducts in my current model and testing it in RevitPythonShell . I have only one linked model, so didn’t need to filter etc

import clr
from Autodesk.DesignScript.Geometry import *
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Mechanical import *
l_doc = ""
linked_docs = FilteredElementCollector(doc).OfClass(RevitLinkInstance)
for link in linked_docs:
	l_doc = link.GetLinkDocument()

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

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
        	lstIntersect.append([duct, pointIntersect.ToPoint() ])

OUT = lstIntersect

running it like this will give the error “‘NoneType’ object has no attribute ‘Intersect’”
so I change the line where I am collecting walls to

linked_walls = FilteredElementCollector(l_doc).OfClass(Wall).WhereElementIsElementType()

now, I don’t have any errors, but the output list is blank !

I have done some more testing and if I have all the walls and ducts in the same file, ie no linked model, then the script works and report the coordinated of all the intersection points.

So I guess I need to figure out how to transform the linked model so they are in the correct place

wish me luck :smiley:

Hi @Hoss ,

you need to apply 2 transformations,
here is an example with link models with transformation

import clr
import sys
pyEngineName = sys.implementation.name 
#
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS

#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

linked_instances = FilteredElementCollector(doc).OfClass(RevitLinkInstance)

pipes = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_PipeCurves).WhereElementIsNotElementType()

lstIntersect = []

for pipe in pipes:
    curvpipe = pipe.Location.Curve
    for link_inst in linked_instances:
        l_doc = link_inst.GetLinkDocument()
        l_tf = link_inst.GetTotalTransform()
        linked_walls = FilteredElementCollector(l_doc).OfClass(Wall).WhereElementIsNotElementType()
        for wall in linked_walls:
            linkrefface = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Interior)
            intFace = wall.GetGeometryObjectFromReference(linkrefface[0])
            # apply the inversion of transformation on curve
            curvetf = curvpipe.CreateTransformed(l_tf.Inverse)
            if pyEngineName == "ironpython":
                interArRef = clr.Reference[IntersectionResultArray]()
                clash = intFace.Intersect(curvetf, interArRef) == SetComparisonResult.Overlap
                clashPoint = interArRef.Value[0].XYZPoint if clash else None
            else:
                dummy_out = IntersectionResultArray()
                result, interResultArr = intFace.Intersect(curvetf, dummy_out)
                clash = result == SetComparisonResult.Overlap
                clashPoint = interResultArr[0].XYZPoint if clash else None
            if clash:
                # revserse the transformation
                clashPoint = l_tf.OfPoint(clashPoint)
                lstIntersect.append([pipe, wall, clashPoint.ToPoint() ])

OUT = lstIntersect
1 Like

Hello @c.poupin
Firstly I would like to thank you for your help
For your information, I have the architect model linked to my MEP model. So walls are from linked model and ducts, pipes etc are in the current document.
When I try your script, I get this error

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed. 
Traceback (most recent call last):
  File "<string>", line 45, in <module>
AttributeError: 'NoneType' object has no attribute 'Intersect'

this is the line

clash = intFace.Intersect(curvetf, interArRef) == SetComparisonResult.Overlap

Thanks again for your time

the error indicates the variable “intFace” is null, try to debug filtering the culprit walls (curtain walls?)

1 Like

Thank you very much for your help
I should have noticed that as I did print out the results from that line and I could see some null values :crazy_face:
Thanks again

1 Like