Problem getting visible subcategory elements

Problem getting visible subcategory elements

michael-coffey
Advocate Advocate
219 Views
1 Reply
Message 1 of 2

Problem getting visible subcategory elements

michael-coffey
Advocate
Advocate

I'm trying to get the visible elements of a subcategory, Property Line Segments.  This particular subcategory allows independent elements, meaning they don't show as a Site category element even though its nested under it.  When using the following code in a view where Property Line Segments is off, it will return the number of segments, assuming you have some.  The expected value would be 0 (since the subcategory is off).  When you turn off the Site category, then it returns 0.  Is this a bug?   

Tested in rac_advanced_sample_project.rvt:

public void GetVisibleSubCategoryElements()
{
	Document doc = this.ActiveUIDocument.Document;
			
	var propLineSegCat = Category.GetCategory(doc, BuiltInCategory.OST_SitePropertyLineSegment);
	var elemList = new FilteredElementCollector(doc, doc.ActiveView.Id).OfCategoryId(propLineSegCat.Id).ToElements().ToList();
			
	TaskDialog.Show("Info", elemList.Count + " elements found.");
}

 

0 Likes
Accepted solutions (1)
220 Views
1 Reply
Reply (1)
Message 2 of 2

michael-coffey
Advocate
Advocate
Accepted solution

Nevermind, seems as though you would need to use OST_SiteProperty instead of OST_SitePropertyLineSegment