I have code here that will list all tags currently placed on a view. I'd like to show tags that aren't placed also. I'd like to see all the available tags even if no tags are placed. Here's what I have.
ElementClassFilter elementFilter = new ElementClassFilter(typeof(IndependentTag)); FilteredElementCollector coll = new FilteredElementCollector(doc, doc.ActiveView.Id); coll.WherePasses(elementFilter); List<IndependentTag> TagList = coll.OfType<IndependentTag>().ToList(); foreach (IndependentTag it in TagList) { Element el = doc.GetElement(it.Id) as Element; MessageBox.Show(it.Name.ToString()); }
Any help is appreciated. Thanks!
Solved! Go to Solution.
Solved by peterjegan. Go to Solution.
Try this:
Change:
FilteredElementCollector coll = new FilteredElementCollector(doc, doc.ActiveView.Id);
To:
FilteredElementCollector coll = new FilteredElementCollector(doc);
This solution does not work, I have tried to get the unused tags in a Revit project, and the code above only gives you tags that are used somewhere in the project, if they are just in the family list, they do not get included in the filter.
IEnumerable<IndependentTag> tags = new FilteredElementCollector(doc).OfClass(typeof(IndependentTag)).Cast<IndependentTag>();
FilteredElementCollector taglcollector = new FilteredElementCollector(doc);
ICollection<Element> taglcollection = taglcollector.OfClass(typeof(IndependentTag)).ToElements();
ElementClassFilter elementFilter = new ElementClassFilter(typeof(IndependentTag));
FilteredElementCollector coll = new FilteredElementCollector(doc);
coll.WherePasses(elementFilter);
List<IndependentTag> TagList = coll.OfType<IndependentTag>().ToList();
each of these examples only give you tags that are somewhere in the project (placed). I have twenty tag types in my families list that do not get captured by these filters?? How do I access tags not used "anywhere at all" in a project?