i want to check whether tag is present on door by api how should i checked?

i want to check whether tag is present on door by api how should i checked?

prasannamurumkar
Advocate Advocate
1,632 Views
4 Replies
Message 1 of 5

i want to check whether tag is present on door by api how should i checked?

prasannamurumkar
Advocate
Advocate

i have collected doors present in my project by

FilteredElementCollector collector = new FilteredElementCollector(activeDoc, vp.ViewId).OfCategory(BuiltInCategory.OST_Doors).WhereElementIsNotElementType();

some doors has door tag on door i just wants to verify it how should i proceed?

0 Likes
Accepted solutions (1)
1,633 Views
4 Replies
Replies (4)
Message 2 of 5

aignatovich
Advisor
Advisor
Accepted solution

Hi!

 

You can find all IndependentTag-s, presented in the document of OST_DoorTags category and all doors ids:

 

var collector = new FilteredElementCollector(doc);
var doorTagsIds = new HashSet<ElementId>(collector.OfClass(typeof(IndependentTag)).OfCategory(BuiltInCategory.OST_DoorTags).OfType<IndependentTag>().Select(x => x.GetTaggedLocalElement()?.Id).Where(x => x != null));

Then you can iterate your doors collection and check if doorTagsIds contains door.Id 

 

Message 3 of 5

prasannamurumkar
Advocate
Advocate

thank you for reply it is working fine by comparing each id in door with doortag.

0 Likes
Message 4 of 5

prasannamurumkar
Advocate
Advocate
var doorTagsIds = new HashSet<ElementId>(collector.OfClass(typeof(IndependentTag)).OfCategory(BuiltInCategory.OST_DoorTags).OfType<IndependentTag>().Select(x => x.GetTaggedLocalElement()?.Id).Where(x => x != null));

this collect door not doortag

able to collect door tag by this

 FilteredElementCollector Collector1 = new FilteredElementCollector(activeDoc, vp.ViewId).OfCategory(BuiltInCategory.OST_DoorTags).WhereElementIsNotElementType();

 

but now my problem is getting collection doorTags Ids.But to compare with doors ids are different than their tags.

So how do we get relation between element and element Tag?

So that able to verify whether element is contain tag or not? 

0 Likes
Message 5 of 5

jeremytammik
Autodesk
Autodesk

You can collect door elements on one hand, and independent tag elements on the other.

 

From the independent tag, you can get the door using TaggedLocalElementId:

 

https://apidocs.co/apps/revit/2019/759306d1-5168-ef9a-91e4-494c7eff0b5d.htm

 

To get the tag from the door, you can invert this relationship:

 

http://thebuildingcoder.typepad.com/blog/2008/10/relationship-in.html

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes