Revit API取得全部元素
2013-11-04 12:19
169 查看
//取得全部元素
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class cmdGetAll : IExternalCommand
{
public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elements)
{
UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
//全部元素
FilteredElementCollector collectorAll = new FilteredElementCollector(uiDoc.Document);
collectorAll.WherePasses(new LogicalOrFilter(new ElementIsElementTypeFilter(false), new ElementIsElementTypeFilter(true)));
TaskDialog.Show("全部", collectorAll.Count().ToString());
//IsElement
FilteredElementCollector collectorIs = new FilteredElementCollector(uiDoc.Document);
collectorIs.WherePasses(new ElementIsElementTypeFilter(true));
TaskDialog.Show("IsElement", collectorIs.Count().ToString());
//IsNotElement
FilteredElementCollector collectorIsNot = new FilteredElementCollector(uiDoc.Document);
collectorIsNot.WherePasses(new ElementIsElementTypeFilter(false));
TaskDialog.Show("IsNotElement", collectorIsNot.Count().ToString());
//数量
int ductAll = 0;
int ductIs = 0;
int ductIsNot = 0;
foreach (Element el in collectorAll)
{
if (el is Duct)
ductAll += 1;
}
foreach (Element el in collectorIs)
{
if (el is Duct)
ductIs += 1;
}
foreach (Element el in collectorIsNot)
{
if (el is Duct)
ductIsNot += 1;
}
TaskDialog.Show("duct", ductAll + "," + ductIs + "," + ductIsNot);
return Result.Succeeded;
}
}url:http://greatverve.cnblogs.com/p/get-all-element.html
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class cmdGetAll : IExternalCommand
{
public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elements)
{
UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
//全部元素
FilteredElementCollector collectorAll = new FilteredElementCollector(uiDoc.Document);
collectorAll.WherePasses(new LogicalOrFilter(new ElementIsElementTypeFilter(false), new ElementIsElementTypeFilter(true)));
TaskDialog.Show("全部", collectorAll.Count().ToString());
//IsElement
FilteredElementCollector collectorIs = new FilteredElementCollector(uiDoc.Document);
collectorIs.WherePasses(new ElementIsElementTypeFilter(true));
TaskDialog.Show("IsElement", collectorIs.Count().ToString());
//IsNotElement
FilteredElementCollector collectorIsNot = new FilteredElementCollector(uiDoc.Document);
collectorIsNot.WherePasses(new ElementIsElementTypeFilter(false));
TaskDialog.Show("IsNotElement", collectorIsNot.Count().ToString());
//数量
int ductAll = 0;
int ductIs = 0;
int ductIsNot = 0;
foreach (Element el in collectorAll)
{
if (el is Duct)
ductAll += 1;
}
foreach (Element el in collectorIs)
{
if (el is Duct)
ductIs += 1;
}
foreach (Element el in collectorIsNot)
{
if (el is Duct)
ductIsNot += 1;
}
TaskDialog.Show("duct", ductAll + "," + ductIs + "," + ductIsNot);
return Result.Succeeded;
}
}url:http://greatverve.cnblogs.com/p/get-all-element.html
相关文章推荐
- Revit API取得变量的内参名称实例代码
- Revit API遍历全部风管,找到与风管相关的墙开洞(向量计算)
- Revit API过滤元素类别(FamilySymbol与FamilyInstance)
- Revit API布置喷头(放置任何元素的方法类似)
- RevitAPI: 如何获取MirrorElement函数镜像之后的结果元素
- Revit 2015 API 的全部变化和新功能
- 关于Revit API修改元素参数的问题?
- Revit API取得变量的内参名称
- Revit API根据参数类型取得参数的值
- Revit API元素镜像MirrorElement
- [Silverlight入门系列]用TransformToVisual和Transform取得元素绝对位置(Location)
- jQuery子窗体取得父窗体的元素
- 用CSS验证页面元素--MatchesSelector API
- RevitAPI之深入了解组(Group)和应用组
- 详谈用API读取Revit对象的参数值
- Solr中清空全部元素
- List接口下Vector的API全部方法的用法(上)
- jQuery LigerUI V1.1.6 (包括API和全部源码) 发布
- WebDriver API(3)简单元素操作
- [算法系列之二十二]包含T全部元素的最小子窗口