How to get the bounding segments of a room?

How to get the bounding segments of a room?

Anonymous
Not applicable
469 Views
1 Reply
Message 1 of 2

How to get the bounding segments of a room?

Anonymous
Not applicable

I am using the following code: I am trying to  get all the bounding segments of each room. But the list is not getting populated by the method of the Rooms class. 

 

room.GetBoundarySegments(boundaryOptions);

 

private List<int> GetElementIdsOfWallsEnclosingRooms()
        {
            List<int> elementIdsOfWalls = new List<int>();
            Document doc = commandData.Application.ActiveUIDocument.Document;
            FilteredElementCollector collector = new FilteredElementCollector(doc);
            collector.OfCategory(BuiltInCategory.OST_Rooms);
            IList<IList<BoundarySegment>> boundarySegments;
            foreach (Room room in collector)
            {
                SpatialElementBoundaryOptions boundaryOptions = new SpatialElementBoundaryOptions();
                boundaryOptions.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.CoreCenter;
                boundaryOptions.StoreFreeBoundaryFaces = true;
boundarySegments = room.GetBoundarySegments(boundaryOptions); IList<BoundarySegment> boundarySegmentList = boundarySegments.ElementAt(0); foreach (BoundarySegment boundarySegment in boundarySegmentList) { elementIdsOfWalls.Add(boundarySegment.ElementId.IntegerValue); } } return elementIdsOfWalls; }

 

Is there any problem with SpecialElementBoundaryOptions?

The value inside boundarySegments has 0 lists.

0 Likes
470 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

I think it is because you aren't looping through every List in the List (sounds confusing, I know).

 

replace your loop with this:

 

            foreach (Room room in collector)
            {
                SpatialElementBoundaryOptions boundaryOptions = new SpatialElementBoundaryOptions();
                boundaryOptions.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.CoreCenter;
                boundaryOptions.StoreFreeBoundaryFaces = true;
boundarySegments = room.GetBoundarySegments(boundaryOptions);
// IList<BoundarySegment> boundarySegmentList = boundarySegments.ElementAt(0);
foreach(IList<BoundarySegment> boundarySegmentList in boundarySegments)
{ foreach (BoundarySegment boundarySegment in boundarySegmentList) { elementIdsOfWalls.Add(boundarySegment.ElementId.IntegerValue); }
} }
0 Likes