Message 1 of 2
Trouble with getting families from specific category element

Not applicable
08-26-2015
09:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone!
I've been looking for ways to get the families who are in specific category, but in some categories, my code don't shows me some families.
This is my code for looking Families in Categories, I hope you will support me.
int iViewID = Convert.ToInt32(lbView.Text); ElementId id = new ElementId(iViewID); int iCategory = Convert.ToInt32(cmbCategory.SelectedValue.ToString()); ElementId catID = new ElementId(iCategory); List<string> lstFamily = new List<string>(); List<string> lstFamilyType = new List<string>(); Dictionary<string, List<FamilySymbol>> FamilyTypes = new FilteredElementCollector(docM) .WherePasses(new ElementClassFilter(typeof(FamilySymbol))) .OfCategoryId(catID) .Cast<FamilySymbol>() .GroupBy(e3 => e3.Family.Name) .ToDictionary(e3 => e3.Key, e3 => e3.ToList()); foreach (KeyValuePair<string, List<FamilySymbol>> entry in FamilyTypes) { lstFamily.Add(entry.Key); foreach (FamilySymbol item in entry.Value) { Debug.Print(item.Name); lstFamilyType.Add(item.Name); } } cmbFamily.DataSource = lstFamily;
Cheers!