<?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: GetBoundarySegments doc.GetElement(segment.ElementId) doesn't work as expect in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9556896#M33865</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;IList&amp;lt;IList&amp;lt;BoundarySegment&amp;gt;&amp;gt; loops = room.GetBoundarySegments(options);
List&amp;lt;Wall&amp;gt; walls = new List&amp;lt;Wall&amp;gt;();

foreach(var loop in loops)
{
   foreach(var segment in loops)
   {
      Element e = doc.GetElement(segment.ElementId);
      if (e is Wall)
         walls.Add(e as Wall);
   }                
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Trying your approach in C# works fine.&lt;/P&gt;&lt;P&gt;I created some closed wall boundary and outer limits with Room Separator.&lt;/P&gt;&lt;P&gt;Collection walls return all walls that are boundary for the room.&lt;/P&gt;&lt;P&gt;Have you tried the code on new sample project?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 03 Jun 2020 07:57:52 GMT</pubDate>
    <dc:creator>lukaskohout</dc:creator>
    <dc:date>2020-06-03T07:57:52Z</dc:date>
    <item>
      <title>GetBoundarySegments doc.GetElement(segment.ElementId) doesn't work as expected</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9554153#M33860</link>
      <description>&lt;P&gt;I'm using the following code to try to get all exterior&amp;nbsp;&lt;STRONG&gt;Walls&lt;/STRONG&gt;&amp;nbsp;using &lt;STRONG&gt;GetBoundarySegments&lt;/STRONG&gt; .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Specifically I'm creating a huge room at the model extents, then identifying walls inside that room. (see image)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="roomBoundaryissue.JPG" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/778573i9C2B0C9EB216A5EE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="roomBoundaryissue.JPG" alt="roomBoundaryissue.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;def GetWallsFromRoomBoundaries(doc, room):
	ids = []
	loops = room.GetBoundarySegments( SpatialElementBoundaryOptions() )
	for loop in loops:
		for segment in loop:
			print(segment)
			neighbor= doc.GetElement(segment.ElementId)
            print(neighbor)

	        if neighbor.GetType().ToString() == "Autodesk.Revit.DB.Wall":
				ids.Add(neighbor.Id)

	return ids&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;print(segments)&lt;/STRONG&gt; outputs 2 loops;&lt;/P&gt;&lt;P&gt;- the 4 outside room boundaries&lt;/P&gt;&lt;P&gt;- an array of all the boundary segments of the walls (image above)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But &lt;STRONG&gt;print(neighbor)&lt;/STRONG&gt; outputs only 2 wall elements.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm confused as to why &lt;STRONG&gt;doc.GetElement(segment.ElementId)&lt;/STRONG&gt; doesn't work as expected.&lt;/P&gt;&lt;P&gt;I'm using&amp;nbsp;&lt;STRONG&gt;Revit 2019&lt;/STRONG&gt;, and I understood from the Revit API Documentation that &lt;STRONG&gt;segment.Element&lt;/STRONG&gt; is deprecated so I can't use that directly to get the element touching the room boundary.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2020 07:50:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9554153#M33860</guid>
      <dc:creator>AH_Yafim</dc:creator>
      <dc:date>2020-06-02T07:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundarySegments doc.GetElement(segment.ElementId) doesn't work as expect</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9555708#M33861</link>
      <description>&lt;P&gt;I don't typically work in VB, but my guess is that&lt;/P&gt;&lt;LI-CODE lang="general"&gt;if neighbor.GetType().ToString() == "Autodesk.Revit.DB.Wall":&lt;/LI-CODE&gt;&lt;P&gt;is the problem.&amp;nbsp; In c# i would say&lt;/P&gt;&lt;LI-CODE lang="general"&gt;if (neighbor is Wall)&lt;/LI-CODE&gt;&lt;P&gt;i think you are getting the wall's type and asking if the string is the class name heirarchy.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2020 18:47:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9555708#M33861</guid>
      <dc:creator>michael-coffey</dc:creator>
      <dc:date>2020-06-02T18:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundarySegments doc.GetElement(segment.ElementId) doesn't work as expect</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9556008#M33862</link>
      <description>&lt;P&gt;In VB:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;If Typeof(neighbor) is Wall then
....&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If that's the problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Michel&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2020 20:30:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9556008#M33862</guid>
      <dc:creator>TripleM-Dev.net</dc:creator>
      <dc:date>2020-06-02T20:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundarySegments doc.GetElement(segment.ElementId) doesn't work as expect</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9556631#M33863</link>
      <description>&lt;P&gt;Not really sure why it is doing that, but I had the same result where it only return one wall even though they were all walls. I got it to work by using a separate definition.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#Preparing input from dynamo to revit
element = UnwrapElement(IN[0])

#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

def GetWallsFromRoomBoundaries(doc, room):
	ids = []
	loops = room.GetBoundarySegments(SpatialElementBoundaryOptions())
	for loop in loops:
		for segment in loop:
			neighbor = doc.GetElement(segment.ElementId)
	        #if neighbor.GetType() == Wall:
			ids.Add(doc.GetElement(neighbor.Id))
	return ids
	
def GetWalls(elems):
	walls = []
	for e in elems:
		if e.GetType() == Wall:
			walls.Add(e)
	return walls

TransactionManager.Instance.TransactionTaskDone()

boundaries = GetWallsFromRoomBoundaries(doc, element)

OUT = GetWalls(boundaries)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 03 Jun 2020 05:20:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9556631#M33863</guid>
      <dc:creator>Sean_Page</dc:creator>
      <dc:date>2020-06-03T05:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundarySegments doc.GetElement(segment.ElementId) doesn't work as expect</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9556751#M33864</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;Thank you for the answers.&lt;/P&gt;&lt;P&gt;I think my question might have included code that was misleading to what I am asking.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is &lt;STRONG&gt;NOT&lt;/STRONG&gt; with the line:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;if neighbor.GetType().ToString() == "Autodesk.Revit.DB.Wall":&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is with the code that comes &lt;STRONG&gt;just before&lt;/STRONG&gt; that:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;print(segment)
neighbor = doc.GetElement(segment.ElementId)
print(neighbor)&lt;/LI-CODE&gt;&lt;P&gt;The first print gives me all the correct elements, but the second print &lt;STRONG&gt;only outputs 2 walls&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regardless, I've tried also to play with your suggestions of the &lt;STRONG&gt;if&lt;/STRONG&gt; statement and tried:&lt;/P&gt;&lt;P&gt;(BTW I'm writing in Python, not VB)&lt;/P&gt;&lt;LI-CODE lang="general"&gt;if neighbor.GetType() == Wall:

if type(neighbor) == Wall:&lt;/LI-CODE&gt;&lt;P&gt;but both of these didn't improve any results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again, the &lt;STRONG&gt;if&lt;/STRONG&gt; statement isn't the issue. The problem is with the code &lt;STRONG&gt;BEFORE&lt;/STRONG&gt; that.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;doc.GetElement(segment.ElementId)&lt;/LI-CODE&gt;&lt;P&gt;The code doesn't retrieve all the elements from the segments,&amp;nbsp; so something is wrong here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hoping you can help.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 06:44:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9556751#M33864</guid>
      <dc:creator>AH_Yafim</dc:creator>
      <dc:date>2020-06-03T06:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundarySegments doc.GetElement(segment.ElementId) doesn't work as expect</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9556896#M33865</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;IList&amp;lt;IList&amp;lt;BoundarySegment&amp;gt;&amp;gt; loops = room.GetBoundarySegments(options);
List&amp;lt;Wall&amp;gt; walls = new List&amp;lt;Wall&amp;gt;();

foreach(var loop in loops)
{
   foreach(var segment in loops)
   {
      Element e = doc.GetElement(segment.ElementId);
      if (e is Wall)
         walls.Add(e as Wall);
   }                
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Trying your approach in C# works fine.&lt;/P&gt;&lt;P&gt;I created some closed wall boundary and outer limits with Room Separator.&lt;/P&gt;&lt;P&gt;Collection walls return all walls that are boundary for the room.&lt;/P&gt;&lt;P&gt;Have you tried the code on new sample project?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 07:57:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9556896#M33865</guid>
      <dc:creator>lukaskohout</dc:creator>
      <dc:date>2020-06-03T07:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundarySegments doc.GetElement(segment.ElementId) doesn't work as expect</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9556914#M33866</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I tried it now on a new project, with 4 walls creating a closed boundary.&lt;/P&gt;&lt;P&gt;This is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;def RetrieveWallBoundaries(doc, room):
	wallElementIds = []
	loops = room.GetBoundarySegments( SpatialElementBoundaryOptions() )

	for loop in loops:
		for segment in loop:	
			print(segment)
			neighbor = doc.GetElement(segment.ElementId)
	        print(type(neighbor))
	        	        
	        if type(neighbor) == Wall:
				wallElementIds.Add(neighbor.Id)

	return wallElementIds&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output from the 2 print statements in the segment loop is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;&amp;lt;Autodesk.Revit.DB.BoundarySegment object at 0x0000000000001195 [Autodesk.Revit.DB.BoundarySegment]&amp;gt;
&amp;lt;Autodesk.Revit.DB.BoundarySegment object at 0x0000000000001196 [Autodesk.Revit.DB.BoundarySegment]&amp;gt;
&amp;lt;Autodesk.Revit.DB.BoundarySegment object at 0x0000000000001197 [Autodesk.Revit.DB.BoundarySegment]&amp;gt;
&amp;lt;Autodesk.Revit.DB.BoundarySegment object at 0x0000000000001198 [Autodesk.Revit.DB.BoundarySegment]&amp;gt;
&amp;lt;type 'ModelLine'&amp;gt;
&amp;lt;Autodesk.Revit.DB.BoundarySegment object at 0x0000000000001199 [Autodesk.Revit.DB.BoundarySegment]&amp;gt;
&amp;lt;Autodesk.Revit.DB.BoundarySegment object at 0x000000000000119A [Autodesk.Revit.DB.BoundarySegment]&amp;gt;
&amp;lt;Autodesk.Revit.DB.BoundarySegment object at 0x000000000000119B [Autodesk.Revit.DB.BoundarySegment]&amp;gt;
&amp;lt;Autodesk.Revit.DB.BoundarySegment object at 0x000000000000119C [Autodesk.Revit.DB.BoundarySegment]&amp;gt;
&amp;lt;type 'Wall'&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So as mentioned before, the code finds the large room boundary segments, which don't have walls generating them, and it also finds the 4 boundary segments which are defined by those simple 4 walls, but it only recognizes 1 of those walls in the&amp;nbsp; &lt;STRONG&gt;neighbor = doc.GetElement(segment.ElementId) line.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 08:10:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9556914#M33866</guid>
      <dc:creator>AH_Yafim</dc:creator>
      <dc:date>2020-06-03T08:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundarySegments doc.GetElement(segment.ElementId) doesn't work as expect</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9556936#M33867</link>
      <description>&lt;P&gt;Did you try using the additional definition like I showed above? Basically I couldn't get them do loop and "type" in the same def, but it worked fine when I split them up.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 08:21:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9556936#M33867</guid>
      <dc:creator>Sean_Page</dc:creator>
      <dc:date>2020-06-03T08:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundarySegments doc.GetElement(segment.ElementId) doesn't work as expect</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9556970#M33868</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;The definition you suggested was a bit confusing because you return a variable called ids but actually it contains wall elements.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In any case I tried to replicate it:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;def RetrieveWallBoundaries(doc, room):
	wallElements = []
	loops = room.GetBoundarySegments( SpatialElementBoundaryOptions() )

	for loop in loops:
		for segment in loop:
			#print(segment)
			neighbor = doc.GetElement(segment.ElementId)
	        #print(type(neighbor))
	        wallElements.Add(neighbor)        
	return wallElements


def GetWallids(wallElements):
	wallids = []
	for w in wallElements:
		if w.GetType() == Wall:
			wallids.Add(w.Id)
			print(w)
	return wallids


# MAIN
walls = RetrieveWallBoundaries(doc, room)
ids = GetWallids(walls)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The print(w) line still only prints 1 wall....&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 08:35:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9556970#M33868</guid>
      <dc:creator>AH_Yafim</dc:creator>
      <dc:date>2020-06-03T08:35:49Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundarySegments doc.GetElement(segment.ElementId) doesn't work as expect</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9556986#M33869</link>
      <description>&lt;P&gt;So, not sure why, but I think it has to do with the GetElement and then translating that back to .Id.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works for me it just doesn't use the "neighbor" translation:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def RetrieveWallBoundaries(doc, room):
	wallElementIds = []
	loops = room.GetBoundarySegments(SpatialElementBoundaryOptions())
	for loop in loops:
		for i in range(len(loop)):
			if type(doc.GetElement(loop[i].ElementId)) == Wall:
				wallElementIds.Add(loop[i].ElementId)
	return wallElementIds&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 08:45:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9556986#M33869</guid>
      <dc:creator>Sean_Page</dc:creator>
      <dc:date>2020-06-03T08:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundarySegments doc.GetElement(segment.ElementId) doesn't work as expect</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9557005#M33870</link>
      <description>&lt;P&gt;Extremely strange that with a range iteration it works but not otherwise..&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thank you for the creative workaround!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe someone will see this post later on and enlighten us why this behavior exists.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 08:54:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getboundarysegments-doc-getelement-segment-elementid-doesn-t/m-p/9557005#M33870</guid>
      <dc:creator>AH_Yafim</dc:creator>
      <dc:date>2020-06-03T08:54:12Z</dc:date>
    </item>
  </channel>
</rss>

