Search code examples
revit-apirevitrevitpythonshell

Get a room's neighbours within Revit 2017 API


I am trying to browse all rooms (or actually all spaces) of a building, in order to get the list of adjacent spaces to each of these spaces. I have read some quite old posts about it here and here, but these use the "Element" property of BoundarySegment objects, e.g.:

foreach( BoundarySegment s in b )
...
Element neighbour = s.Element;

If I'm not mistaken, this is no longer possible to access the wall objects from a BoundarySegment (?) Is there an alternative?

Thanks,

Arnaud.


Solution

  • Got to http://www.revitapidocs.com

    Search for BoundarySegment class.

    I get the message: "2017 | Resource Not Available for the Active API Year... Resource Only Available for 2015".

    Look at What's New in the Revit 2017 API:

    http://thebuildingcoder.typepad.com/blog/2016/04/whats-new-in-the-revit-2017-api.html

    Obsolete API removal lists Autodesk.Revit.DB.BoundarySegment.Element.

    The two posts that you mention above are:

    http://thebuildingcoder.typepad.com/blog/2013/09/room-neighbours.html

    http://thebuildingcoder.typepad.com/blog/2009/01/room-and-wall-adjacency.html

    All the code provided in both of them is included in The Building Coder samples:

    https://github.com/jeremytammik/the_building_coder_samples

    The Building Coder samples are maintained on GitHub and migrated to new versions of the Revit API as they come along. Therefore, you can see how to achieve the same thing in Revit 2017 on GitHub, at:

    https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/CmdRoomWallAdjacency.cs

    https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/CmdRoomNeighbours.cs