本文整理汇总了C#中FilteredElementCollector.UnionWith方法的典型用法代码示例。如果您正苦于以下问题:C# FilteredElementCollector.UnionWith方法的具体用法?C# FilteredElementCollector.UnionWith怎么用?C# FilteredElementCollector.UnionWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilteredElementCollector
的用法示例。
在下文中一共展示了FilteredElementCollector.UnionWith方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ListAllElements
/// <summary>
/// List all elements in Revit database.
/// </summary>
void ListAllElements()
{
// Create an output file:
string filename = Path.Combine(
Path.GetTempPath(), "RevitElements.txt");
StreamWriter sw = new StreamWriter(filename);
// The Revit API does not expect an application
// ever to need to iterate over all elements.
// To do so, we need to use a trick: ask for all
// elements fulfilling a specific criteria and
// unite them with all elements NOT fulfilling
// the same criteria; an arbitrary criterion
// could be chosen:
FilteredElementCollector collector
= new FilteredElementCollector(_doc)
.WhereElementIsElementType();
FilteredElementCollector collector2
= new FilteredElementCollector(_doc)
.WhereElementIsNotElementType();
collector.UnionWith(collector2);
// Loop over the elements and list their data:
string s, line;
foreach (Element e in collector)
{
line = "Id=" + e.Id.IntegerValue.ToString(); // element id
line += "; Class=" + e.GetType().Name; // element class, i.e. System.Type
// The element category is not implemented for all classes,
// and may return null; for family elements, one can sometimes
// use the FamilyCategory property instead.
s = string.Empty;
if (null != e.Category)
{
s = e.Category.Name;
}
if (0 == s.Length && e is Family && null != ((Family)e).FamilyCategory)
{
s = ((Family)e).FamilyCategory.Name;
}
if (0 == s.Length)
{
s = "?";
}
line += "; Category=" + s;
// The element Name property has a different meaning for different classes,
// but is mostly implemented 'logically'. More precise info on elements
// can be obtained in class-specific ways.
line += "; Name=" + e.Name;
//line += "; UniqueId=" + e.UniqueId;
//line += "; Guid=" + GetGuid( e.UniqueId );
sw.WriteLine(line);
}
sw.Close();
TaskDialog.Show("List all elements",
string.Format("Element list has been written to '{0}'.", filename));
}