Tuesday, November 9, 2010

Revit Room Boundaries

This came up today at work: For a given room, what are the room bounding objects?

Questions like these can easily be solved with RevitPythonShell. So I fired up an RPS shell and came up with the following script:

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB.Architecture import Room
from Autodesk.Revit.DB import Wall

sel = __revit__.ActiveUIDocument.Selection.Elements
rooms = [e for e in sel if type(e) is Room]
for room in rooms:
    for bsa in room.Boundary:     # bsa = BoundarySegmentArray
        for bs in bsa:            # bs = BoundarySegment
            print bs.Element

This gets you quite close. I added a featured script to the RPS site that can be used as an RPS command and prints the element id for boundary segments that are model elements.

No comments:

Post a Comment