Revit API过滤元素类别(FamilySymbol与FamilyInstance)
仅OfCategory()过滤的元素包含系统FamilySymbol
OfClass(typeof(FamilyInstance))过滤出来文档中族实例。
url:http://greatverve.cnblogs.com/p/api-get-symbol-instance.html
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;
}
}
我这个博客废弃不用了,今天想寻找外链的时候,突然想到这个博客权重很高。
有需要免费外链的,留言即可,我准备把这个博客变成免费的友情链接站点。