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: 

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

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
prasannamurumkar
1118 Views, 4 Replies

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

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?

4 REPLIES 4
Message 2 of 5

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

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

Message 4 of 5

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? 

Message 5 of 5

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

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