本文整理汇总了C#中FilteredElementCollector.OfCategoryId方法的典型用法代码示例。如果您正苦于以下问题:C# FilteredElementCollector.OfCategoryId方法的具体用法?C# FilteredElementCollector.OfCategoryId怎么用?C# FilteredElementCollector.OfCategoryId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilteredElementCollector
的用法示例。
在下文中一共展示了FilteredElementCollector.OfCategoryId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClsCategory
public ClsCategory(Category cat, Document doc)
{
_Cat = cat;
_Doc = doc;
FilteredElementCollector col = new FilteredElementCollector(doc);
col.OfCategoryId(cat.Id).WhereElementIsNotElementType();
_InstanceElements = col.ToElements().ToList();
}
示例2: GetTargetInstances
/// <summary>
/// Return all element instances for a given
/// category, identified either by a built-in
/// category or by a category name.
/// </summary>
public static FilteredElementCollector GetTargetInstances(
Document doc,
object targetCategory)
{
FilteredElementCollector collector
= new FilteredElementCollector( doc );
bool isName = targetCategory.GetType().Equals(
typeof( string ) );
if ( isName )
{
Category cat = doc.Settings.Categories
.get_Item( targetCategory as string );
collector.OfCategoryId( cat.Id );
}
else
{
collector.WhereElementIsNotElementType();
collector.OfCategory( (BuiltInCategory) targetCategory );
//var model_elements
// = from e in collector
// where ( null != e.Category && e.Category.HasMaterialQuantities )
// select e;
//elements = model_elements.ToList<Element>();
}
return collector;
}
示例3: GetTargetInstances
/// <summary>
/// Helper to get all instances for a given category,
/// identified either by a built-in category or by a category name.
/// </summary>
public static List<Element> GetTargetInstances(
Document doc,
object targetCategory)
{
List<Element> elements;
bool isName = targetCategory.GetType().Equals( typeof( string ) );
if( isName )
{
Category cat = doc.Settings.Categories.get_Item( targetCategory as string );
FilteredElementCollector collector = new FilteredElementCollector( doc );
collector.OfCategoryId( cat.Id );
elements = new List<Element>( collector );
}
else
{
FilteredElementCollector collector
= new FilteredElementCollector( doc )
.WhereElementIsNotElementType();
collector.OfCategory( (BuiltInCategory) targetCategory );
// I removed this to test attaching a shared
// parameter to Material elements:
//
//var model_elements = from e in collector
// where ( null != e.Category && e.Category.HasMaterialQuantities )
// select e;
//elements = model_elements.ToList<Element>();
elements = collector.ToList<Element>();
}
return elements;
}