Revit API取得全部元素
//取得全部元素
[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;
}
}
[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;
}
}
我这个博客废弃不用了,今天想寻找外链的时候,突然想到这个博客权重很高。
有需要免费外链的,留言即可,我准备把这个博客变成免费的友情链接站点。