Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

List<> available tags

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
RickyBell
766 Views, 3 Replies

List<> available tags

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!

3 REPLIES 3
Message 2 of 4
peterjegan
in reply to: RickyBell

Try this:

 

Change:

 

FilteredElementCollector coll = new FilteredElementCollector(doc, doc.ActiveView.Id);

 

To:

 

FilteredElementCollector coll = new FilteredElementCollector(doc);

 

 

Message 3 of 4
dhorsburgh
in reply to: RickyBell

Where do I do this at within Civil 3D 2017/18? I really like to see a list of tags used and unused.

 

David

Tags (1)
Message 4 of 4
arautio
in reply to: peterjegan

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?

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community