OfClass(typeof(FamilyInstance))过滤出来文档中族实例。
//过滤元素类别
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class cmdGetCate : IExternalCommand
{
public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elements)
{
UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
Transaction ts = new Transaction(uiDoc.Document, "SetFamily");
ts.Start();
FilteredElementCollector collector = new FilteredElementCollector(uiDoc.Document);
collector.OfCategory(BuiltInCategory.OST_DuctFitting);//过滤出来系统包含的Symbol与文档包含的Instance
//collector.OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_DuctFitting);
int iSymbol = 0;
int iFi = 0;
foreach (Element el in collector)
{
if (el is FamilySymbol)
iSymbol += 1;
else if (el is FamilyInstance)
iFi += 1;
}
TaskDialog.Show("count", iSymbol + "," + iFi);
ts.Commit();
return Result.Succeeded;
}
}
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class cmdGetCate : IExternalCommand
{
public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elements)
{
UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
Transaction ts = new Transaction(uiDoc.Document, "SetFamily");
ts.Start();
FilteredElementCollector collector = new FilteredElementCollector(uiDoc.Document);
collector.OfCategory(BuiltInCategory.OST_DuctFitting);//过滤出来系统包含的Symbol与文档包含的Instance
//collector.OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_DuctFitting);
int iSymbol = 0;
int iFi = 0;
foreach (Element el in collector)
{
if (el is FamilySymbol)
iSymbol += 1;
else if (el is FamilyInstance)
iFi += 1;
}
TaskDialog.Show("count", iSymbol + "," + iFi);
ts.Commit();
return Result.Succeeded;
}
}