0

Working with VS 2008 and Autodesk Revit MEP 2010 in C# I am trying to find out if a door is connecting to rooms:

ElementSetIterator elementsetiteratorBIMDoors = 
  bimdoors.getBIMDoors().ForwardIterator();

while (elementsetiteratorBIMDoors.MoveNext())
{
    Autodesk.Revit.Element elementDoor = 
      elementsetiteratorBIMDoors.Current as Autodesk.Revit.Element;

    if ((null != elementDoor.get_Parameter(BuiltInParameter.FROM_ROOM_ID)) && 
        (null != elementDoor.get_Parameter(BuiltInParameter.TO_ROOM_ID)))
    {
        string sDoorFromRoomID = 
              elementDoor.get_Parameter(BuiltInParameter.FROM_ROOM_ID).ToString();
        string sDoorToRoomID = 
              elementDoor.get_Parameter(BuiltInParameter.TO_ROOM_ID).ToString();

        graph.addLink(new Link(sDoorFromRoomID, sDoorToRoomID));
    }
}

This approach does not work because the return value of elementDoor.get_Parameter(BuiltInParameter.FROM_ROOM_ID) is always null.

I have read on the Building Coder blog that

Built-in parameters are not an officially supported portion of API. In future we expect it will be replaced by data being properly exposed as a property.

Is that statement true? Can anyone point me to an efficient way to get the relation between doors and rooms?

skeletank
  • 2,880
  • 5
  • 43
  • 75
  • It took a while but i found one solution which works at least in my case. May it helps someone else too. Iterate over all rooms. For every room find the boundary segments. Get the curve of the boundary segment. Tesselate the curve of the boundary segment. Works like a projection on the floor. Intersect the result with the projected boundary box of the door. If there is an intersection than the door is hosted by the room. If someone else finds a better way to get connection between room and door i will be glad to hear about it because my approach is a little bit cumbersome. –  Oct 30 '09 at 13:57

1 Answers1

0

Doors are family instances, so

Autodesk.Revit.Elements.FamilyInstance elementDoor = elementsetiteratorBIMDoors.Current as Autodesk.Revit.Elements.FamilyInstance;

Room fromRoom = elementDoor.FromRoom;
Room toRoom = elementDoor.ToRoom;

should work for this.

Zoinks
  • 810
  • 7
  • 4