<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Get intersections between Walls and Ducts in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/7510419#M64988</link>
    <description>&lt;P&gt;I got red underline in FindWallCurve.&lt;/P&gt;&lt;P&gt;How should be a correction?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;   Curve wallCurve = FindWallCurve(w, height);&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Naing Oo&lt;/P&gt;</description>
    <pubDate>Thu, 02 Nov 2017 07:22:08 GMT</pubDate>
    <dc:creator>thannaingoo.api</dc:creator>
    <dc:date>2017-11-02T07:22:08Z</dc:date>
    <item>
      <title>Get intersections between Walls and Ducts</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/6375158#M64986</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I'm trying to get a List&amp;lt;BoundingBoxXYZ&amp;gt; or a List&amp;lt;XYZ&amp;gt; of every intersections between Walls and Ducts in the current Document.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far i'm only getting the two List&amp;lt;ElementsId&amp;gt; (walls and Ducts).&amp;nbsp;&lt;BR /&gt;Here is a sample :&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public Result Execute(
      ExternalCommandData commandData,
      ref string message,
      ElementSet elements)
    {
        try
        {
            UIApplication uiApp = commandData.Application;
            Document doc = uiApp.ActiveUIDocument.Document;
            View view = doc.ActiveView;


            FilteredElementCollector allWalls = new FilteredElementCollector(doc).OfClass(typeof(Wall));
            FilteredElementCollector allDucts = new FilteredElementCollector(doc).OfClass(typeof(Duct));

            List&amp;lt;ElementId&amp;gt; WallsBB = new List&amp;lt;ElementId&amp;gt;();
            List&amp;lt;ElementId&amp;gt; DuctsBB = new List&amp;lt;ElementId&amp;gt;();

            foreach (Element wall in allWalls)
            {
                //BoundingBoxXYZ bbWall = wall.get_BoundingBox(view);
                WallsBB.Add(wall.Id);
            }

            foreach (Element duct in allDucts)
            {
                DuctsBB.Add(duct.Id);
            }
//Here is some function i tried to use, with no result so far.
            FilteredElementCollector collector = new FilteredElementCollector(doc);
            ExclusionFilter exclusionFilter = new ExclusionFilter(WallsBB);
            
            collector.WherePasses(exclusionFilter);

        }
        catch(Exception e)
        {
            TaskDialog.Show("e = ", e.ToString());
        }

        return Result.Succeeded;
    }&lt;/PRE&gt;&lt;P&gt;Thank you !&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2016 15:06:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/6375158#M64986</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-09T15:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: Get intersections between Walls and Ducts</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/6376239#M64987</link>
      <description>&lt;P&gt;Here you are, please don't forget to mark this reply as an answer&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;#region Namespaces

using System;
using System.Text;
using System.Linq;
using System.Xml;
using System.Reflection;
using System.ComponentModel;
using System.Collections;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media.Imaging;
using System.Windows.Forms;
using System.IO;

using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;

using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Events;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.DB.Structure;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.DB.Electrical;
using Autodesk.Revit.DB.Plumbing;

using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.UI.Events;

//using Autodesk.Revit.Collections;
using Autodesk.Revit.Exceptions;
using Autodesk.Revit.Utility;

using RvtApplication = Autodesk.Revit.ApplicationServices.Application;
using RvtDocument = Autodesk.Revit.DB.Document;

#endregion

namespace RevitAddinCS2
{
    [Transaction(TransactionMode.Manual)]
    [Regeneration(RegenerationOption.Manual)]
    public class ExtCmd : IExternalCommand
    {
        #region Cached Variables

        private static ExternalCommandData _cachedCmdData;

        public static UIApplication CachedUiApp
        {
            get
            {
                return _cachedCmdData.Application;
            }
        }

        public static RvtApplication CachedApp
        {
            get
            {
                return CachedUiApp.Application;
            }
        }

        public static RvtDocument CachedDoc
        {
            get
            {
                return CachedUiApp.ActiveUIDocument.Document;
            }
        }

        #endregion

        #region IExternalCommand Members

        public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elemSet)
        {
            _cachedCmdData = cmdData;

            try
            {
                //TODO: add your code below.
                // Find intersections between family instances and a selected element

                FilteredElementCollector WallCollector = new FilteredElementCollector(CachedDoc);
                WallCollector.OfClass(typeof(Wall));
                List&amp;lt;Wall&amp;gt; walls = WallCollector.Cast&amp;lt;Wall&amp;gt;().ToList();

                FilteredElementCollector DuctCollector = new FilteredElementCollector(CachedDoc);
                DuctCollector.OfClass(typeof(Duct));

                List&amp;lt;Duct&amp;gt; ducts = DuctCollector.Cast&amp;lt;Duct&amp;gt;().ToList();
                List&amp;lt;XYZ&amp;gt; points = new List&amp;lt;XYZ&amp;gt;();

                foreach (Duct d in ducts)
                {
                    foreach (Wall w in walls)
                    {
                        Curve ductCurve = FindDuctCurve(d);
                        double height = ductCurve.GetEndPoint(0).Z;

                        Curve wallCurve = FindWallCurve(w, height);

                        XYZ intersection = null;

                        List&amp;lt;Face&amp;gt; wallFaces = FindWallFace(w);

                        foreach (Face f in wallFaces)
                        {
                            intersection = FindFaceCurve(ductCurve, f);
                            if (null != intersection)
                                points.Add(intersection);
                        }
                    }
                }

                StringBuilder sb = new StringBuilder();

                foreach (XYZ p in points)
                {
                    sb.AppendLine(p.ToString());
                }
                TaskDialog.Show("Revit", sb.ToString());

                return Result.Succeeded;
            }
            catch (Exception ex)
            {
                msg = ex.ToString();
                return Result.Failed;
            }
        }

        //Find the wind pipe corresponding curve
        public Curve FindDuctCurve(Duct duct)
        {
            //The wind pipe curve
            IList&amp;lt;XYZ&amp;gt; list = new List&amp;lt;XYZ&amp;gt;();
            ConnectorSetIterator csi = duct.ConnectorManager.Connectors.ForwardIterator();
            while (csi.MoveNext())
            {
                Connector conn = csi.Current as Connector;
                list.Add(conn.Origin);
            }
            Curve curve = Line.CreateBound(list.ElementAt(0), list.ElementAt(1)) as Curve;
            curve.MakeUnbound();
            
            return curve;
        }
        
        public List&amp;lt;Face&amp;gt; FindWallFace(Wall wall)
        {
            List&amp;lt;Face&amp;gt; normalFaces = new List&amp;lt;Face&amp;gt;();

            Options opt = new Options();
            opt.ComputeReferences = true;
            opt.DetailLevel = ViewDetailLevel.Fine;
            
            GeometryElement e = wall.get_Geometry(opt);

            foreach (GeometryObject obj in e)
            {
                Solid solid = obj as Solid;

                if (solid != null &amp;amp;&amp;amp; solid.Faces.Size &amp;gt; 0)
                {
                    foreach (Face face in solid.Faces)
                    {
                        PlanarFace pf = face as PlanarFace;
                        if (pf != null)
                        {
                            normalFaces.Add(pf);
                        }
                    }
                }
            }
            return normalFaces;
        }

        public XYZ FindFaceCurve(Curve DuctCurve, Face WallFace)
        {
            //The intersection point
            IntersectionResultArray intersectionR = new IntersectionResultArray();//Intersection point set
            
            SetComparisonResult results;//Results of Comparison

            results = WallFace.Intersect(DuctCurve, out intersectionR);
            
            XYZ intersectionResult = null;//Intersection coordinate
            
            if (SetComparisonResult.Disjoint != results)
            {
                if (intersectionR != null)
                {
                    if (!intersectionR.IsEmpty)
                    {
                        intersectionResult = intersectionR.get_Item(0).XYZPoint;
                    }
                }
            }
            return intersectionResult;
        }
        
        #endregion

    }
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 00:08:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/6376239#M64987</guid>
      <dc:creator>Mustafa.Salaheldin</dc:creator>
      <dc:date>2016-06-10T00:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Get intersections between Walls and Ducts</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/7510419#M64988</link>
      <description>&lt;P&gt;I got red underline in FindWallCurve.&lt;/P&gt;&lt;P&gt;How should be a correction?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;   Curve wallCurve = FindWallCurve(w, height);&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Naing Oo&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2017 07:22:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/7510419#M64988</guid>
      <dc:creator>thannaingoo.api</dc:creator>
      <dc:date>2017-11-02T07:22:08Z</dc:date>
    </item>
    <item>
      <title>Re: Get intersections between Walls and Ducts</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/11229923#M64989</link>
      <description>&lt;P&gt;Do you find the solution? I get the same mistake&lt;span class="lia-unicode-emoji" title=":sad_but_relieved_face:"&gt;😥&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2022 15:27:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/11229923#M64989</guid>
      <dc:creator>tamsann</dc:creator>
      <dc:date>2022-06-12T15:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: Get intersections between Walls and Ducts</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/11394726#M64990</link>
      <description>&lt;P&gt;findwallcurve is missing can you please add it&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 08:20:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/11394726#M64990</guid>
      <dc:creator>Houba3314</dc:creator>
      <dc:date>2022-09-01T08:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: Get intersections between Walls and Ducts</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/11394764#M64991</link>
      <description>&lt;P&gt;Did you find any solution?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 08:46:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/11394764#M64991</guid>
      <dc:creator>Houba3314</dc:creator>
      <dc:date>2022-09-01T08:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: Get intersections between Walls and Ducts</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/11395210#M64992</link>
      <description>&lt;P&gt;I can notice that after getting the wall location curve at a specific height, Eng.&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1227311"&gt;@Mustafa.Salaheldin&lt;/a&gt;&amp;nbsp; didn't use it at all in this sample,&amp;nbsp;&lt;BR /&gt;so I think you can just remove this line&lt;/P&gt;&lt;PRE&gt;Curve wallCurve = FindWallCurve(w, height);&lt;/PRE&gt;&lt;P&gt;and the code will work fine&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 13:12:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/11395210#M64992</guid>
      <dc:creator>Omar_Amen</dc:creator>
      <dc:date>2022-09-01T13:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: Get intersections between Walls and Ducts</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/11395617#M64993</link>
      <description>&lt;P&gt;yea i noticed that too thanks. hey quick question is it possible that i can insert an element at that intersection?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 15:34:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/11395617#M64993</guid>
      <dc:creator>Houba3314</dc:creator>
      <dc:date>2022-09-01T15:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: Get intersections between Walls and Ducts</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/11396789#M64994</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12007284"&gt;@Houba3314&lt;/a&gt;&amp;nbsp;sorry for late reply, as&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8594778"&gt;@Omar_Amen&lt;/a&gt;&amp;nbsp;said, this line I forgot to remove as this solution was part of bigger one. The idea was to get the intersection between the WallFace (not WallCurve) and the DuctCurve so that way you get set of intersection points.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2022 04:34:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/11396789#M64994</guid>
      <dc:creator>Mustafa.Salaheldin</dc:creator>
      <dc:date>2022-09-02T04:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: Get intersections between Walls and Ducts</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/11396793#M64995</link>
      <description>My advice to you is always try to understand the logic of the procedure, if any part of the code doesn't make sense in terms of the logic context or it is not used some where else in the module, then this means you can remove it safely without disrupting the flow.</description>
      <pubDate>Fri, 02 Sep 2022 04:38:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/11396793#M64995</guid>
      <dc:creator>Mustafa.Salaheldin</dc:creator>
      <dc:date>2022-09-02T04:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: Get intersections between Walls and Ducts</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/11443789#M64996</link>
      <description>&lt;P&gt;Hello, Could you give some suggestions to get intersection between wall curve and duct curve, I want to insert a fire damper at the intersection point. Thank you!!!!!&lt;/P&gt;</description>
      <pubDate>Sun, 25 Sep 2022 10:27:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/11443789#M64996</guid>
      <dc:creator>tamsann</dc:creator>
      <dc:date>2022-09-25T10:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: Get intersections between Walls and Ducts</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/11479853#M64997</link>
      <description>&lt;P&gt;hello again i was wondering for the intersection between floor and ducts is it the same code? .&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 11:39:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/11479853#M64997</guid>
      <dc:creator>Houba3314</dc:creator>
      <dc:date>2022-10-13T11:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: Get intersections between Walls and Ducts</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/13294696#M64998</link>
      <description>&lt;P&gt;About two years ago, when i just start Revit API, i saw your code.. get it and use some parts. Now i start read "Clear Code" by RobertMatrin and&amp;nbsp; remebered your code. Understanding wondering of it. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Feb 2025 18:51:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/13294696#M64998</guid>
      <dc:creator>csvFC98Y</dc:creator>
      <dc:date>2025-02-01T18:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: Get intersections between Walls and Ducts</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/13295002#M64999</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12492898"&gt;@csvFC98Y&lt;/a&gt;&amp;nbsp;Thanks a lot. I feel flattered.&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2025 04:17:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-intersections-between-walls-and-ducts/m-p/13295002#M64999</guid>
      <dc:creator>Mustafa.Salaheldin</dc:creator>
      <dc:date>2025-02-02T04:17:00Z</dc:date>
    </item>
  </channel>
</rss>

