Search code examples
c#revit-apirevit

How do I obtain room seperators in revit 2017


I'm working an application which requires knowledge about which room border which other. In this situation it's relevant to know if a room border is a wall or a room seperator.

 public FindsRoomSeperators(){
        SpatialElementBoundaryOptions options = new SpatialElementBoundaryOptions();
        options.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish;

        foreach (IList<Autodesk.Revit.DB.BoundarySegment> boundSegList in room.GetBoundarySegments(options))
                {
                    foreach (Autodesk.Revit.DB.BoundarySegment boundSeg in boundSegList)
                            if ((BuiltInCategory)el.Category.Id.IntegerValue == BuiltInCategory.OST_RoomSeparationLines)
                                 //proccess el
                 }
   }

However as the of revit 2017 this code now throws the Method not found: 'Autodesk.Revit.DB.Element Autodesk.Revit.DB.BoundarySegment.get_Element()'. exception suggesting that this method has been removed.

      var geometry = (Solid)room.get_Geometry(new Options()).First();
      var faces = geometry.Faces;

And while this does allow me to judge stuff like whatever or not a floor is standing at an angle it does not tell me which of the edges come from walls and which from room sepeartors.

Ideally I would be able to take the faces we have and check to see if any of the edges of a face is a room seperator. I already have a list of all walls if that helps.

So how does one do this in revit 2017? Preferably without breaking compatability with 2015.


Solution

  • That's expected and documented on the Revit Platform API Changes and Additions file (see SDK), this method was marked as deprecated on 2016 and was removed on 2017.

    Instead you should use ElementId or LinkElementId (see documentation).

    foreach (Autodesk.Revit.DB.BoundarySegment boundSeg in boundSegList)
    {
      Element el = doc.GetElement(boundSeg.ElementId); // or doc.GetElement(boundSeg.LinkElementId);
      if ((BuiltInCategory)el.Category.Id.IntegerValue == BuiltInCategory.OST_RoomSeparationLines)
      {
    
      }
    }