过滤器的使用
程序员文章站
2024-02-26 18:49:04
...
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Document revitDoc = commandData.Application.ActiveUIDocument.Document; //取得文档
UIApplication uiApp = commandData.Application;
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Autodesk.Revit.ApplicationServices.Application revitApp = commandData.Application.Application; //取得应用程序
FilteredElementCollector elementcollects = new FilteredElementCollector(revitDoc );//创建一个收集器
//创建一个过滤器
**ElementCategoryFilter elementCategoryFilter = new ElementCategoryFilter(BuiltInCategory.OST_Walls);
elementcollects = elementcollects.WherePasses(elementCategoryFilter);**
MessageBox.Show(elementcollects.Count().ToString());
foreach (Element item in elementcollects)
{
MessageBox.Show(item.Name);
}
return Result.Succeeded;
}
以上是筛选出了 组类型和族实例 注意 墙体没有族实例
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Document revitDoc = commandData.Application.ActiveUIDocument.Document; //取得文档
UIApplication uiApp = commandData.Application;
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Autodesk.Revit.ApplicationServices.Application revitApp = commandData.Application.Application; //取得应用程序
**FilteredElementCollector elementcollects = new FilteredElementCollector(revitDoc );//创建一个收集器
//创建一个过滤器
ElementClassFilter elementClassFilter = new ElementClassFilter(typeof(Wall));**
elementcollects = elementcollects.WherePasses(elementClassFilter);
/*.OfClass(typeof(FamilyInstance));*/
MessageBox.Show(elementcollects.Count().ToString());
foreach (Element item in elementcollects)
{
MessageBox.Show(item.Name);
}
return Result.Succeeded;
}
上面只是筛选出了墙的“实例”
namespace ClassLibrary1
{
[Transaction(TransactionMode.Manual)]
public class Command : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Document revitDoc = commandData.Application.ActiveUIDocument.Document; //取得文档
UIApplication uiApp = commandData.Application;
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Autodesk.Revit.ApplicationServices.Application revitApp = commandData.Application.Application; //取得应用程序
FilteredElementCollector elementcollects = new FilteredElementCollector(revitDoc );//创建一个收集器
//创建一个过滤器
**ElementCategoryFilter elementCategoryFilter = new ElementCategoryFilter(BuiltInCategory.OST_StructuralFraming);
elementcollects = elementcollects.WherePasses(elementCategoryFilter);**/*.OfClass(typeof(FamilyInstance));*/
MessageBox.Show(elementcollects.Count().ToString());
foreach (Element item in elementcollects)
{
MessageBox.Show(item.Name);
}
return Result.Succeeded;
}
}
}
以上筛选出了族类型 和族实例
namespace ClassLibrary1
{
[Transaction(TransactionMode.Manual)]
public class Command : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Document revitDoc = commandData.Application.ActiveUIDocument.Document; //取得文档
UIApplication uiApp = commandData.Application;
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Autodesk.Revit.ApplicationServices.Application revitApp = commandData.Application.Application; //取得应用程序
FilteredElementCollector elementcollects = new FilteredElementCollector(revitDoc );//创建一个收集器
//创建一个过滤器
**ElementCategoryFilter elementCategoryFilter = new ElementCategoryFilter(BuiltInCategory.OST_StructuralFraming);
elementcollects = elementcollects.WherePasses(elementCategoryFilter).OfClass(typeof(FamilyInstance));**
MessageBox.Show(elementcollects.Count().ToString());
foreach (Element item in elementcollects)
{
MessageBox.Show(item.Name);
}
return Result.Succeeded;
}
}
以上就是筛选出了 所有的梁的族实例
上一篇: ExtJS MVC 案例实践(一)
推荐阅读
-
阿里Java学习路线:阶段 1:Java语言基础-Java面向对象编程:第20章:接口的定义与使用:课时91:代理设计模式
-
Linux之ARM(MX6U)裸机按键输入实验(GPIO的输出与输入)
-
python的另一种打印方式:pprint
-
MySQL高级查询之与Group By集合使用介绍
-
阿里Java学习路线:阶段 1:Java语言基础-Java面向对象编程:第7章:数组的定义与使用:课时29:数组与方法
-
阿里Java学习路线:阶段 1:Java语言基础-Java面向对象编程:第7章:数组的定义与使用:课时26:数组引用传递分析
-
过滤器的使用
-
Android自定义viewgroup 使用adapter适配数据(6)
-
听说,你的Loki还是单体?(上篇)
-
Andriod 获取电池的信息实例代码