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
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
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.
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.
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.
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.
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.
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.
Can't find what you're looking for? Ask the community or share your knowledge.