public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
UIApplication app = commandData.Application;
m_doc = app.ActiveUIDocument.Document;
// filter for family instance and (door or window):
ElementClassFilter fFamInstClass = new ElementClassFilter( typeof( FamilyInstance ) );
ElementCategoryFilter fDoorCat = new ElementCategoryFilter( BuiltInCategory.OST_Doors );
ElementCategoryFilter fWindowCat = new ElementCategoryFilter( BuiltInCategory.OST_Windows );
LogicalOrFilter fCat = new LogicalOrFilter( fDoorCat, fWindowCat );
LogicalAndFilter f = new LogicalAndFilter( fCat, fFamInstClass );
FilteredElementCollector openings = new FilteredElementCollector( m_doc );
openings.WherePasses( f );
// map with key = host element id and
// value = list of hosted element ids:
Dictionary<ElementId, List<ElementId>> ids =
GetElementIds( openings );
DumpHostedElements( ids );
m_doc = null;
return Result.Succeeded;
}