I am trying to create a ribbon button command for selecting a device of a certain BuiltInCategory and placing it using doc.PostRequestForElementTypePlacement(elementType).
It works, however the Type Selector in the properties palette seems to display all of the families I have loaded in. Is there any way to restrict or filter what gets displayed in the type selector?
class Communication : IExternalCommand { Application app; Document doc; public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiApp = commandData.Application; UIDocument uiDoc = uiApp.ActiveUIDocument; app = uiApp.Application; doc = uiDoc.Document; FilteredElementCollector CommunicationsCollector = new FilteredElementCollector(doc); CommunicationsCollector.OfClass(typeof(FamilySymbol)); CommunicationsCollector.OfCategory(BuiltInCategory.OST_CommunicationDevices); if (CommunicationsCollector.FirstElement() == null) { TaskDialog.Show("Electrical Devices", "No Communication Devices family is loaded in the project."); return Result.Cancelled; } ElementType elemType = CommunicationsCollector.FirstElement() as ElementType; uiDoc.PostRequestForElementTypePlacement(elemType); return Result.Succeeded; } }