Find unhosted tags

Find unhosted tags

Kevin.Bell
Advisor Advisor
1,826 Views
4 Replies
Message 1 of 5

Find unhosted tags

Kevin.Bell
Advisor
Advisor

Hi,

 

I have an issue with tags when tagging objects which are linked into the current model.

 

This mainly happens with Doors, the tags are placed in the Main model, and they tag doors which are in one of several building models that are linked.

 

The problem is that when a door is deleted, the tag changes into a '?' as it can't find its host - the issue is that the '?' symbols are difficult to find - I'd like a routine which will select them.

 

I can get the door tags with a FilteredElementCollectotor:

 

FilteredElementCollector fec_doortags  = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_DoorTags);

I'd like to iterate through the FEC and check if the tags are hosted - but the problem is that I can't find a property or parameter which refers to the host.

 

I've tried the IndependantTag Class - but I believe this only refers to the tagged element, not the tag itself.

 

Is there any way I can test the tag element to find out if its hosted or not?

 

Thanks.

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

RPTHOMAS108
Mentor
Mentor
Accepted solution

IndependentTag represents the tag element not the element tagged.

 

It has property "IsOrphaned" which tells you if the tag item is associated with an element from a link that no longer exists.

 

Also IndependentTag.TaggedElementId can also be used to check for such instances. It returns a LinkedElementID object whose HostElementId, LinkElementId & LinkInstanceId will all be set to ElementID.InvalidElementID.

 

Generally when filtering for elements in the entire model rather than view you should call 'WhereElementIsNotElementType'.

0 Likes
Message 3 of 5

Kevin.Bell
Advisor
Advisor

Perfect! - Thanks for your help.

0 Likes
Message 4 of 5

cgambleTFFSQ
Advocate
Advocate

I am completely ignorant about FilteredElementCollector, im assuming its a developer thing, but I have a similar thing where I'm trying to filter all unhosted wall tags and delete them. How can I accomplish this with a FilteredElementCollector, if its even assessable by a regular revit user and not a developer? 

0 Likes
Message 5 of 5

jeremytammik
Autodesk
Autodesk

The filtered element collector is a class provided by the Revit API.

 

It is accessibly programmatically only.

 

As an end user, you do in fact have easy access to the Revit API and programming functionality via the built-in macro development environment, the SharpDevelop IDE, or integrated development environment.

 

For more information on this, please refer to the numerous Revit macro programming tutorials and the Revit API getting started material:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#2

 



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

0 Likes