<?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: Getting ceilings and floors from Room in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/getting-ceilings-and-floors-from-room/m-p/7774047#M58964</link>
    <description>&lt;P&gt;Yeah that would definitely be a better solution. I've implemented the random probing (though you have to cap the count or you risk hanging the program indefinitely) but this is something I should implement down the road. The success of the probing method is linearly proportional to the area of the bounding box the room fills. large L hallways for example have a low success rate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I suppose with any of these scripts there are assumptions on how the file was built and what geometry is accessible. Realistically they're not going to work in every fringe case.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the insight.&lt;/P&gt;</description>
    <pubDate>Tue, 13 Feb 2018 14:02:18 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-02-13T14:02:18Z</dc:date>
    <item>
      <title>Getting ceilings and floors from Room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getting-ceilings-and-floors-from-room/m-p/7029105#M58958</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;I have some room in selection and I need to get some informations about individual floors and ceilings (area and material) which are part of room.&lt;/P&gt;&lt;P&gt;I tried to use BoundarySegment and Faces of room, but i didn't get all elements wich part of the boundary, especially ceilings.&lt;/P&gt;&lt;P&gt;I don't won't to use a geometry, but i can't find any reliable solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 10:25:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getting-ceilings-and-floors-from-room/m-p/7029105#M58958</guid>
      <dc:creator>autodesk</dc:creator>
      <dc:date>2017-04-20T10:25:43Z</dc:date>
    </item>
    <item>
      <title>Re: Getting ceilings and floors from Room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getting-ceilings-and-floors-from-room/m-p/7029208#M58959</link>
      <description>&lt;P&gt;User&amp;nbsp;Reference Intersector as per the following example taking from the RevitAPI.CHM which comes with the Revit API SDK Package:&lt;/P&gt;
&lt;PRE&gt;public class RayProjection : IExternalCommand
{
    public Result Execute(ExternalCommandData revit, ref string message, ElementSet elements)
    {
        Document doc = revit.Application.ActiveUIDocument.Document;

        Selection selection = revit.Application.ActiveUIDocument.Selection;

        // If skylight is selected, process it.
        FamilyInstance skylight = null;
        if (selection.Elements.Size == 1)
        {
            foreach (Element e in selection.Elements)
            {
                if (e is FamilyInstance)
                {
                    FamilyInstance instance = e as FamilyInstance;
                    bool isWindow = (instance.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Windows);
                    bool isHostedByRoof = (instance.Host.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Roofs);

                    if (isWindow &amp;amp;&amp;amp; isHostedByRoof)
                    {
                        skylight = instance;
                    }
                }
            }
        }

        if (skylight == null)
        {
            message = "Please select one skylight.";
            return Result.Cancelled;
        }

        // Calculate the height
        Line line = CalculateLineAboveFloor(doc, skylight);

        // Create a model curve to show the distance
        Plane plane = revit.Application.Application.Create.NewPlane(new XYZ(1, 0, 0), line.GetEndPoint(0));
        SketchPlane sketchPlane = SketchPlane.Create(doc, plane);

        ModelCurve curve = doc.Create.NewModelCurve(line, sketchPlane);

        // Show a message with the length value
        TaskDialog.Show("Distance", "Distance to floor: " + String.Format("{0:f2}", line.Length));

        return Result.Succeeded;
    }

    /// &amp;lt;summary&amp;gt;
    /// Determines the line segment that connects the skylight to the nearest floor.
    /// &amp;lt;/summary&amp;gt;
    /// &amp;lt;returns&amp;gt;The line segment.&amp;lt;/returns&amp;gt;
    private Line CalculateLineAboveFloor(Document doc, FamilyInstance skylight)
    {
        // Find a 3D view to use for the ReferenceIntersector constructor
        FilteredElementCollector collector = new FilteredElementCollector(doc);
        Func&amp;lt;View3D, bool&amp;gt; isNotTemplate = v3 =&amp;gt; !(v3.IsTemplate);
        View3D view3D = collector.OfClass(typeof(View3D)).Cast&amp;lt;View3D&amp;gt;().First&amp;lt;View3D&amp;gt;(isNotTemplate);

        // Use the center of the skylight bounding box as the start point.
        BoundingBoxXYZ box = skylight.get_BoundingBox(view3D);
        XYZ center = box.Min.Add(box.Max).Multiply(0.5);

        // Project in the negative Z direction down to the floor.
        XYZ rayDirection = new XYZ(0, 0, -1);

        ElementClassFilter filter = new ElementClassFilter(typeof(Floor));

        ReferenceIntersector refIntersector = new ReferenceIntersector(filter, FindReferenceTarget.Face, view3D);
        ReferenceWithContext referenceWithContext = refIntersector.FindNearest(center, rayDirection);

        Reference reference = referenceWithContext.GetReference();
        XYZ intersection = reference.GlobalPoint;

        // Create line segment from the start point and intersection point.
        Line result = Line.CreateBound(center, intersection);
        return result;
    }
}
&lt;/PRE&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;
&lt;P&gt;Thanks, Ibrahim Naeem&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 11:21:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getting-ceilings-and-floors-from-room/m-p/7029208#M58959</guid>
      <dc:creator>IbrahimNaeem</dc:creator>
      <dc:date>2017-04-20T11:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: Getting ceilings and floors from Room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getting-ceilings-and-floors-from-room/m-p/7039765#M58960</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Dear Petr,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you for your query.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I like your handle 'Autodesk, CEO'&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Please also look at the discussion on getting the ceiling material in a room:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="http://forums.autodesk.com/t5/revit-api-forum/get-ceiling-material-in-room/m-p/6875603" target="_blank"&gt;http://forums.autodesk.com/t5/revit-api-forum/get-ceiling-material-in-room/m-p/6875603&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I hope this helps.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jeremy&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2017 07:18:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getting-ceilings-and-floors-from-room/m-p/7039765#M58960</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2017-04-25T07:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: Getting ceilings and floors from Room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getting-ceilings-and-floors-from-room/m-p/7765841#M58961</link>
      <description>&lt;P&gt;I realize this thread is old but I'm having an issue with something similar.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having the user select a room, and I'm trying to&amp;nbsp;get the ceiling of said room. I originally tried a filtered element collector grabbing ceilings, and then checking to see if the center point of the ceiling exists in my room's bounding box. I had an issue with the iterator saying it was out of elements, so i'm presuming none of the elements passed the comparison. Here's the snippet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;FilteredElementCollector ceilings = new FilteredElementCollector(doc).OfClass(typeof(Ceiling)).OfCategory(BuiltInCategory.OST_Ceilings);
			Element selectedCeiling = null;

			if (ceilings.Count() != 0)
			{
				foreach (Ceiling f in ceilings)
				{
					XYZ ceilingCenter = GetElementCenter(f);
					BoundingBoxXYZ roomBox = selectedRoom.get_BoundingBox(null);
					if (roomBox.Max.X &amp;gt;= ceilingCenter.X &amp;amp;&amp;amp; roomBox.Min.X &amp;lt;= ceilingCenter.X &amp;amp;&amp;amp; roomBox.Max.Y &amp;gt;= ceilingCenter.Y &amp;amp;&amp;amp; roomBox.Min.Y &amp;lt;= ceilingCenter.Y &amp;amp;&amp;amp; roomBox.Max.Z &amp;gt;= ceilingCenter.Z &amp;amp;&amp;amp; roomBox.Min.Z &amp;lt;= ceilingCenter.Z)
					{
						selectedCeiling = f as Element;
					}
					selectedCeiling = f;
					XYZ ceilingCenter = GetElementCenter(f);
				}
			}&lt;/PRE&gt;&lt;P&gt;From there I searched the forums and saw this thread recommending using a reference intersector to ray cast into the ceiling. So, I tried this method as posted above, but I keep getting null references. I'm not sure if my type is wrong in the ElementClassFilter, or I thought maybe the co ordinate system in Revit might be y up instead of z up, but nothing seems to work. Here is the second snippet.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;XYZ roomCenter = GetElementCenter(selectedRoom);
			XYZ rayDirection = new XYZ(0, 0, 1);

			FilteredElementCollector collector = new FilteredElementCollector(doc);
			Func&amp;lt;View3D, bool&amp;gt; isNotTemplate = v3 =&amp;gt; !(v3.IsTemplate);
			View3D View3D = collector.OfClass(typeof(View3D)).Cast&amp;lt;View3D&amp;gt;().First&amp;lt;View3D&amp;gt;(isNotTemplate);
			ElementClassFilter ceilingFilter = new ElementClassFilter(typeof(Ceiling));


			BoundingBoxXYZ roomBox = selectedRoom.get_BoundingBox(View3D);
			ReferenceIntersector ceilingIntersector = new ReferenceIntersector(ceilingFilter, FindReferenceTarget.Element, View3D);
			ReferenceWithContext referenceWithContext = ceilingIntersector.FindNearest(roomCenter, rayDirection);
			Reference ceilingRef = referenceWithContext.GetReference();
			Element selectedCeiling = doc.GetElement(ceilingRef) as Element;&lt;/PRE&gt;&lt;P&gt;Thanks for this,&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 15:46:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getting-ceilings-and-floors-from-room/m-p/7765841#M58961</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-02-09T15:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Getting ceilings and floors from Room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getting-ceilings-and-floors-from-room/m-p/7766035#M58962</link>
      <description>&lt;P&gt;I solved the problem, but I just thought I would post the solution. The above ray casting works perfectly fine. The issue was one of the test rooms I was using had a courtyard in the center and the ray cast hit nothing and thus returned null.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to think of a decent solution to this problem as there's no point within the BoundinBoxXYZ that would guarantee a hit. You could iterate moving further from the center until you hit something (the battleship method), but there's no guarantee that you'd be heading in a beneficial direction. I suppose you could pick random points within the room and probe them. Does anyone have any better ideas?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 16:46:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getting-ceilings-and-floors-from-room/m-p/7766035#M58962</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-02-09T16:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: Getting ceilings and floors from Room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getting-ceilings-and-floors-from-room/m-p/7767785#M58963</link>
      <description>&lt;P&gt;Thank you for explaining the problem and its cause.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have no&amp;nbsp;off-hand idea for a better solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One way to eliminate the problem without the need for probing would be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Scan all the rooms and determine whether their profiles include any inner loops such as your courtyard.&lt;/LI&gt;
&lt;LI&gt;For each floor with an inner loop, replace the room by a modified version with outer loops only.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example of reading the outline of a floor and creating a new floor using only the first, outer loop:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2008/11/editing-a-floor-profile.html" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2008/11/editing-a-floor-profile.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would have to take more care to find all the outer profile loops, though... they may be more than one, and disjunct:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2017/10/disjunct-outer-loops-from-planar-face-with-separate-parts.html" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2017/10/disjunct-outer-loops-from-planar-face-with-separate-parts.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Sat, 10 Feb 2018 11:56:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getting-ceilings-and-floors-from-room/m-p/7767785#M58963</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2018-02-10T11:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: Getting ceilings and floors from Room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getting-ceilings-and-floors-from-room/m-p/7774047#M58964</link>
      <description>&lt;P&gt;Yeah that would definitely be a better solution. I've implemented the random probing (though you have to cap the count or you risk hanging the program indefinitely) but this is something I should implement down the road. The success of the probing method is linearly proportional to the area of the bounding box the room fills. large L hallways for example have a low success rate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I suppose with any of these scripts there are assumptions on how the file was built and what geometry is accessible. Realistically they're not going to work in every fringe case.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the insight.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 14:02:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getting-ceilings-and-floors-from-room/m-p/7774047#M58964</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-02-13T14:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: Getting ceilings and floors from Room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getting-ceilings-and-floors-from-room/m-p/9716814#M58965</link>
      <description>&lt;P&gt;Its strange. becouse when i&amp;nbsp; try get Celling like that, ReferanceInspector give me null.&lt;/P&gt;&lt;P&gt;but when i create floor upstears Celling, they give me floor, and igronre Celling&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Aug 2020 08:44:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getting-ceilings-and-floors-from-room/m-p/9716814#M58965</guid>
      <dc:creator>fazlul.db</dc:creator>
      <dc:date>2020-08-28T08:44:12Z</dc:date>
    </item>
  </channel>
</rss>

