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: 

how to gets relation of element with its tag or its label?

9 REPLIES 9
Reply
Message 1 of 10
prasannamurumkar
903 Views, 9 Replies

how to gets relation of element with its tag or its label?

I have doors.

I have door tags

want to verify the whether  particular tags present on that  particular door?

 

9 REPLIES 9
Message 2 of 10

Did you RTFM?

 

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

 

TaggedLocalElementId looks like it will do the job.

 

Cheers,

 

Jeremy

 

 

 



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

Message 3 of 10

Also, you already asked this same question and received the same answer before:

 

https://forums.autodesk.com/t5/revit-api-forum/i-want-to-check-whether-tag-is-present-on-door-by-api...

 



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

Message 4 of 10

At that time i thought that answer is correct but actually answer is wrong.

He answered as tag contains same element  id as that of tag.

but tags are different Id than the element ID

also he  given tags we get like this

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

 by this not able to collect door tag it just collects id s of door only.

Message 5 of 10

It collects all independent tags AND the element ids of the doors that they tag.

 



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

Message 6 of 10

Hi All,

 

Given the above property is no longer valid in the current API, what is an updated solution? 

Message 7 of 10

I would assume that this can easily be discovered by snooping the element and its tag and their properties using RevitLookup and other Revit BIM database exploration tools. Have you taken a look at that?

  

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 8 of 10
jrostar
in reply to: jeremy_tammik

You could also assume that people come to public forums asking for help after they have already spent time trying to discover the answer themselves and are hoping that knowledgeable people from the community would be willing to help.
Message 9 of 10
jeremy_tammik
in reply to: jrostar

Yes, indeed! Sometimes I do, and sometimes they have, and sometimes they have not. It takes all sorts...

   

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 10 of 10

There's a saying about assuming... I'll leave it up to you to find on the internet.  

 

For others scraping through these posts looking for a modicum of actual help, here's how I ended up solving it with help from @Mohamed_Arshad (who actually provided some guidance). 


using (Transaction trans = new Transaction(doc, "Tag Parent Doors"))
            {
                trans.Start();

                foreach (FamilyInstance door in doors)
                {
                    if (new FilteredElementCollector(doc, currentView.Id)
                         .OfCategory(BuiltInCategory.OST_DoorTags)
                         .OfClass(typeof(IndependentTag))
                         .Cast<IndependentTag>()
                         .SelectMany(x => x.GetTaggedLocalElementIds())
                         .Where(x => x == door.Id).Any())
                    {
                        skipCount++;
                        continue;
                    }
                }
            }

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