Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top