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: 

Tags and Element

3 REPLIES 3
Reply
Message 1 of 4
sonicer
365 Views, 3 Replies

Tags and Element

sonicer
Collaborator
Collaborator

How can I ease get all tag types for selected element?

Example If I select Wall Element need get all wall tag types?

Which paramater in wall is link to wall tag?

 

thx

 

 

 

0 Likes

Tags and Element

How can I ease get all tag types for selected element?

Example If I select Wall Element need get all wall tag types?

Which paramater in wall is link to wall tag?

 

thx

 

 

 

3 REPLIES 3
Message 2 of 4
naveen.kumar.t
in reply to: sonicer

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @sonicer ,

1)start the transaction

2)Select the element

3)

ElementId eid;
IList<ElementId> eids=doc.Delete(eid) as IList<ElementId>;

4)roll back the transaction

5)

ElementId catgeoryID = null;
foreach(ElementId id in eids)
       {
         Element e1 = doc.GetElement(id);
          if(e1.Category.Name.Contains("Tag"))
             {
               catgeoryID = e1.Category.Id;
             }
         }

ElementCategoryFilter ECF = new ElementCategoryFilter(catgeoryID);

//contains all the tag types of selected element
FilteredElementCollector tagcollector = new FilteredElementCollector(doc).WherePasses(ECF).WhereElementIsElementType() as FilteredElementCollector;

 I hope this helps.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Hi @sonicer ,

1)start the transaction

2)Select the element

3)

ElementId eid;
IList<ElementId> eids=doc.Delete(eid) as IList<ElementId>;

4)roll back the transaction

5)

ElementId catgeoryID = null;
foreach(ElementId id in eids)
       {
         Element e1 = doc.GetElement(id);
          if(e1.Category.Name.Contains("Tag"))
             {
               catgeoryID = e1.Category.Id;
             }
         }

ElementCategoryFilter ECF = new ElementCategoryFilter(catgeoryID);

//contains all the tag types of selected element
FilteredElementCollector tagcollector = new FilteredElementCollector(doc).WherePasses(ECF).WhereElementIsElementType() as FilteredElementCollector;

 I hope this helps.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 3 of 4
sonicer
in reply to: naveen.kumar.t

sonicer
Collaborator
Collaborator

Your code is find all tags linked to element.

But I need get all Tag types list. Not tag family instance created in project.

 

 

thx.

 

0 Likes

Your code is find all tags linked to element.

But I need get all Tag types list. Not tag family instance created in project.

 

 

thx.

 

Message 4 of 4
naveen.kumar.t
in reply to: sonicer

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @sonicer 

1)select the element

2)this below code will list the tag types for the selected element

 

suppose if a wall element is selected this code will return the wall tag types.

Element e;
                Category C = e.Category;

                string categoryName = C.Name.Remove(C.Name.Length - 1, 1);
                string categoryTagName = categoryName + " " + "Tag";

                FilteredElementCollector coll = new FilteredElementCollector(doc).OfClass(typeof(Family));
                foreach(Element e1 in coll)
                {
                   Family f = e1 as Family;
                   if(e1.Name.Contains(categoryTagName))
                   {
                        //contains tag types for selected element
                        ISet<ElementId> famSymIds = f.GetFamilySymbolIds() as ISet<ElementId>;
                   } 
                }

I hope this helps.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes

Hi @sonicer 

1)select the element

2)this below code will list the tag types for the selected element

 

suppose if a wall element is selected this code will return the wall tag types.

Element e;
                Category C = e.Category;

                string categoryName = C.Name.Remove(C.Name.Length - 1, 1);
                string categoryTagName = categoryName + " " + "Tag";

                FilteredElementCollector coll = new FilteredElementCollector(doc).OfClass(typeof(Family));
                foreach(Element e1 in coll)
                {
                   Family f = e1 as Family;
                   if(e1.Name.Contains(categoryTagName))
                   {
                        //contains tag types for selected element
                        ISet<ElementId> famSymIds = f.GetFamilySymbolIds() as ISet<ElementId>;
                   } 
                }

I hope this helps.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

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

Post to forums  

Autodesk Design & Make Report