0
我想遍历图形中的所有设备并获取设备的名称。Revit MEP 2011 C#遍历所有设备
以下是我有:
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;
// get all PanelScheduleView instances in the Revit document.
FilteredElementCollector fec = new FilteredElementCollector(doc);
ElementClassFilter EquipmentViewsAreWanted =
new ElementClassFilter(typeof(ElectricalEquipment));
fec.WherePasses(EquipmentViewsAreWanted);
List<Element> eViews = fec.ToElements() as List<Element>;
StringBuilder Disp = new StringBuilder();
foreach (ElectricalEquipment element in eViews)
{
Disp.Append("\n" + element.);
}
System.Windows.Forms.MessageBox.Show(Disp.ToString());
我得到的foreach
循环以下错误:
无法将类型 'Autodesk.Revit.DB.Element' 到 “欧特克。 Revit.DB.Electrical.ElectricalEquipment'
有什么建议吗?
不完全是答案,但它把我带到了我正在寻找的东西。基本上,您可以使用fec.toArray()而不是toElements将电气设备组合成一个数组;然后迭代。谢谢您的帮助。 – CornCat 2010-09-14 00:28:29