<?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: Create PolyLoop from room.BoundarySegment in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/create-polyloop-from-room-boundarysegment/m-p/10242524#M26555</link>
    <description>&lt;P&gt;If you need to identify the outer loops you will have to do something similar to below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2017/10/disjunct-outer-loops-from-planar-face-with-separate-parts.html" target="_blank"&gt;The Building Coder: Disjunct Planar Face Outer Loops (typepad.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are you saying the extrusion function does not allow inner loops to represent voids?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the end the circle has the same centroid as a donut.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Apr 2021 22:28:38 GMT</pubDate>
    <dc:creator>RPTHOMAS108</dc:creator>
    <dc:date>2021-04-15T22:28:38Z</dc:date>
    <item>
      <title>Create PolyLoop from room.BoundarySegment</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-polyloop-from-room-boundarysegment/m-p/10240684#M26552</link>
      <description>&lt;P&gt;This might be a stupid question, so correct me if I'm completely off.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to leverage the .centroid property of the PolyLoop class, so I can find the center of my L-shaped rooms, but I can't figure out how to get my BoundarySegments to polyloops.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm currently getting the roomBoundarySegment of the room and converting them into polylines in a foreach loop.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public XYZ GetRoomCentroid(Room room)
        {
            IList&amp;lt;IList&amp;lt;BoundarySegment&amp;gt;&amp;gt; roomBoundarySegment = room.GetBoundarySegments(new SpatialElementBoundaryOptions());
            IList&amp;lt;PolyLine&amp;gt; roomPolyLines = null; 
            IList&amp;lt;XYZ&amp;gt; listCoord = null;

            string message = "BoundarySegment:";



            foreach (IList&amp;lt;BoundarySegment&amp;gt; segmentList in roomBoundarySegment)
            {
                foreach (BoundarySegment segment in segmentList)
                {
                    

                    //Get startpoint of curve
                    //message += "\n Curve startpoint (" + segment.GetCurve().GetEndPoint(0).X + "," + segment.GetCurve().GetEndPoint(0).Y + "," + segment.GetCurve().GetEndPoint(0).Z + ")";

                    //Get endpoint of curve 
                    //message += "\n Curve end´point (" + segment.GetCurve().GetEndPoint(1).X + "," + segment.GetCurve().GetEndPoint(1).Y + "," + segment.GetCurve().GetEndPoint(1).Z + ")";


                    
                    XYZ coordinatesStart = new XYZ(segment.GetCurve().GetEndPoint(0).X, segment.GetCurve().GetEndPoint(0).Y, segment.GetCurve().GetEndPoint(0).Z);
                    XYZ coordinatesEnd = new XYZ(segment.GetCurve().GetEndPoint(1).X, segment.GetCurve().GetEndPoint(1).Y, segment.GetCurve().GetEndPoint(1).Z);

                    listCoord.Add(coordinatesStart);
                    listCoord.Add(coordinatesEnd);


                    PolyLine line = PolyLine.Create(listCoord);
                    
                    roomPolyLines.Add(line);
                    
                }
            }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just can't figure out how to convert polylines, curves or anything into a Polyloop where I can call the .Centroid property.&lt;/P&gt;&lt;P&gt;When I look at the RevitAPI documentation it states the a Polyloop is composed of straight lines segments where each endpoint is the same is the previous startpoint - thats what I get when I'm using the BoundarySegment class as far as I understand.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone share some insight on what I'm doing wrong?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 12:24:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-polyloop-from-room-boundarysegment/m-p/10240684#M26552</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-15T12:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: Create PolyLoop from room.BoundarySegment</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-polyloop-from-room-boundarysegment/m-p/10241741#M26553</link>
      <description>&lt;P&gt;That object appears to be associated with EnergyAnalysisSpace class. Not sure it can be created directly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To find centroid you can use your curveloops to create a solid i.e.&amp;nbsp;&lt;/P&gt;&lt;P&gt;GeometryCreationUtilities.CreateExtrusionGeometry(IList(Of CurveLoop), XYZ.Basis.Z, 1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then your solid can be queried for it's centroid.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 16:43:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-polyloop-from-room-boundarysegment/m-p/10241741#M26553</guid>
      <dc:creator>RPTHOMAS108</dc:creator>
      <dc:date>2021-04-15T16:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: Create PolyLoop from room.BoundarySegment</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-polyloop-from-room-boundarysegment/m-p/10242285#M26554</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1035859"&gt;@RPTHOMAS108&lt;/a&gt;&amp;nbsp;Thank you - that works perfectly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Marking your answer as solved.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you happen to know a good way to seperate the curves if I have squares in side another square? right now it gives me an error of unconnected lines, which is true but not my intent.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If a try to create it for the room outside the blue boundary, it gets me 8 curves, which is correct. But how do I make it create that as 1 Curveloop and 1 solid which I can find the centroid from? (the shape in in between the black lines)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mikkelnymand_1-1618514787347.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/907283iF463D70B87C09570/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mikkelnymand_1-1618514787347.png" alt="mikkelnymand_1-1618514787347.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the thelp though! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV class="gtx-trans-icon"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 15 Apr 2021 20:13:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-polyloop-from-room-boundarysegment/m-p/10242285#M26554</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-15T20:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: Create PolyLoop from room.BoundarySegment</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-polyloop-from-room-boundarysegment/m-p/10242524#M26555</link>
      <description>&lt;P&gt;If you need to identify the outer loops you will have to do something similar to below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2017/10/disjunct-outer-loops-from-planar-face-with-separate-parts.html" target="_blank"&gt;The Building Coder: Disjunct Planar Face Outer Loops (typepad.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are you saying the extrusion function does not allow inner loops to represent voids?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the end the circle has the same centroid as a donut.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 22:28:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-polyloop-from-room-boundarysegment/m-p/10242524#M26555</guid>
      <dc:creator>RPTHOMAS108</dc:creator>
      <dc:date>2021-04-15T22:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: Create PolyLoop from room.BoundarySegment</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-polyloop-from-room-boundarysegment/m-p/10242575#M26556</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1035859"&gt;@RPTHOMAS108&lt;/a&gt;&amp;nbsp;Okay - I will check out the link.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No the extrusion function most likely allows it, but the Curveloop does not - it wont accept line that dont connect.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm getting the below error when trying to move the roomtag of the outer room (room 11).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mikkelnymand_0-1618527339703.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/907353i4E449DDC81C97718/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mikkelnymand_0-1618527339703.png" alt="mikkelnymand_0-1618527339703.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've gotten it to work on almost all other shapes I try - some L-, and U-shaped rooms doesn't work, but I'm handling the exceptions for now and skipping the room and outputting it in a Dialog when all other rooms are moved.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is what I've tested on so far, only one of them fails.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mikkelnymand_0-1618527154382.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/907352i6A373D2620218B4C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mikkelnymand_0-1618527154382.png" alt="mikkelnymand_0-1618527154382.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 22:57:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-polyloop-from-room-boundarysegment/m-p/10242575#M26556</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-15T22:57:24Z</dc:date>
    </item>
    <item>
      <title>Re: Create PolyLoop from room.BoundarySegment</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-polyloop-from-room-boundarysegment/m-p/10242587#M26557</link>
      <description>&lt;P&gt;Your issue is your centroid is outside the body of the room (as would usually be the case for O, U and L etc). So centroid can't be used to place the room tag?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 23:03:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-polyloop-from-room-boundarysegment/m-p/10242587#M26557</guid>
      <dc:creator>RPTHOMAS108</dc:creator>
      <dc:date>2021-04-15T23:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: Create PolyLoop from room.BoundarySegment</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-polyloop-from-room-boundarysegment/m-p/10242641#M26558</link>
      <description>&lt;P&gt;Yea, I actually got that, but I’m handling the exceptions with IsInsideRoom - but with the O I’m getting and error in my foreach loop when I create the curveloop.&lt;/P&gt;&lt;P&gt;I was wondering how to catch that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can place the tags, sure. But they need to be inside the room - we would rather have to manually move L and O shaped if centroid can’t place them inside.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;is there a mathematical way to determine a better center for those rooms?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;The only way I see is to use a centroid of one of the straight shapes in the L, by dividing it to into to straight shapes - I just have no idea how to determine this programmatically while also handling normal rooms.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 23:25:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-polyloop-from-room-boundarysegment/m-p/10242641#M26558</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-15T23:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: Create PolyLoop from room.BoundarySegment</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-polyloop-from-room-boundarysegment/m-p/10242694#M26559</link>
      <description>&lt;P&gt;Yes for a CurveLoop the lines must be joined.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you take a horizontal unbound line with origin at your centroid you can test for intersections with this horizontal ray against the curves from your curve loops that you know are associated with that room.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) If you find an odd number of intersection left of your centroid then I believe your centroid is within solid&lt;/P&gt;&lt;P&gt;2) If you find even number of intersections left of your centroid then I believe your centroid is outside solid&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For (2) average the first and second intersections to the left of centroid for a point inside the room just to the left of centroid.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i.e. travelling through all points left of centroid we know that you will ultimately end up outside your room (regardless of if you start inside or out). You either started inside your room in which case you must pass through an odd number of boundaries to get outside. Otherwise you started outside your room needed to pass through one wall the get inside and then an odd number to get back outside (even number).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is how I believe they check these things.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With a horizontal line there is a case where you pass through nothing on the left (reverse C). For 0 intersection you are outside. Would have to consider intersections by taking rays through other directions to find an appropriate inside location for such things e.g. vector between centroid and mid point of curve from one of the curve loops.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 00:23:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-polyloop-from-room-boundarysegment/m-p/10242694#M26559</guid>
      <dc:creator>RPTHOMAS108</dc:creator>
      <dc:date>2021-04-16T00:23:07Z</dc:date>
    </item>
    <item>
      <title>Re: Create PolyLoop from room.BoundarySegment</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-polyloop-from-room-boundarysegment/m-p/10244901#M26560</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1035859"&gt;@RPTHOMAS108&lt;/a&gt;&amp;nbsp;Okay - Thank you for the help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got to work more on this, but for now I'll filter out the once that doesn't work as intended and they can be done manually.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm collection all the failed rooms in a list, and posting it as i dialog afterwards, so people know what rooms didn't get centered.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate the assistance.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 16:32:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-polyloop-from-room-boundarysegment/m-p/10244901#M26560</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-16T16:32:20Z</dc:date>
    </item>
  </channel>
</rss>

