# How to identify orphaned tags?

**URL:** <https://forum.dynamobim.com/t/how-to-identify-orphaned-tags/16076>\
**Category:** Revit\
**Created:** [October 30, 2017, 5:36pm UTC](https://forum.dynamobim.com/t/how-to-identify-orphaned-tags/16076 "2017-10-30T17:36:36Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![rlosh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/rlosh/32/31759_2.png) [@rlosh](https://forum.dynamobim.com/u/rlosh)\
**Post date:** [October 30, 2017, 5:36pm UTC](https://forum.dynamobim.com/t/how-to-identify-orphaned-tags/16076/1 "2017-10-30T17:36:36Z")

</div>

Dear Fellow Dynamaniacs,

Here is what I would like to accomplish: Create a list of all views in the project that have orphaned tags in them (tags that lose their association to an element and display “?” instead of the intended value) so that we can go through and fix them. I’ve started with material tags. Below is the beginning of my effort. I have found other topics on this, like this one [http://dynamobim.org/forums/topic/host-of-tag/](http://dynamobim.org/forums/topic/host-of-tag/). However, I have no knowledge of Python so it doesn’t mean much to me. I’m getting empty lists in the Tag.TagText node instead of a list of strings. Any help is appreciated!

 ![orphan rescue](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/2/92cbe3c3714e4341126ea6c1f6819b94d90f563e.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [October 30, 2017, 6:04pm UTC](https://forum.dynamobim.com/t/how-to-identify-orphaned-tags/16076/2 "2017-10-30T18:04:51Z")

</div>

This will give you inconsistent results with material tags as the **Tag.TagText** node appears to read values from the element not the material of the element which the tag points.

A possible workaround would be to look into using the “is orphaned” property which can be read about here:

> **[IsOrphaned Property](https://www.revitapidocs.com/2017/4906fa9c-e424-92e7-0b7e-15389726ca78.htm)**
>
> Online Documentation for Autodesk's Revit API: 2015, 2016, 2017, 2017.1, 2018

Alternatively you could do a deeper dive into pulling material tag values correctly by referencing the tag value using the method given here:

> **[TagText Property](https://www.revitapidocs.com/2017/8e297dee-920d-f620-6198-0bed494e3f04.htm)**
>
> Online Documentation for Autodesk's Revit API: 2015, 2016, 2017, 2017.1, 2018

Either way these are deeper dives which will entail some coding.

---

<div class="post-metadata">

**Author:** ![rlosh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/rlosh/32/31759_2.png) [@rlosh](https://forum.dynamobim.com/u/rlosh)\
**Post date:** [October 31, 2017, 5:12pm UTC](https://forum.dynamobim.com/t/how-to-identify-orphaned-tags/16076/3 "2017-10-31T17:12:57Z")

</div>

Thanks for the help @jacob.small! I will have to dig deeper.

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [October 31, 2017, 5:35pm UTC](https://forum.dynamobim.com/t/how-to-identify-orphaned-tags/16076/4 "2017-10-31T17:35:52Z")

</div>

@rlosh you may want to watch this conversation as well:

> [@Selecting Tags Associated to a Linked Model](https://forum.dynamobim.com/t/selecting-tags-associated-to-a-linked-model/16118):
>
> Never seen this issue before, and apologies if it’s been covered but a search didn’t turn up anything. I’m unable to select tags via any method which are hosted to a linked model, returning the error in the screenshot below. Any method I can think of (all elements of category, all elements of type, all elements in active view, select model elements, select model element, ID to selection, UI based element pick tools…) which results in selecting these tags causes either a null result, skips the …

---

<div class="post-metadata">

**Author:** ![ChrisRob](https://avatars.discourse-cdn.com/v4/letter/c/4491bb/32.png) [@ChrisRob](https://forum.dynamobim.com/u/ChrisRob)\
**Post date:** [August 4, 2018, 7:38pm UTC](https://forum.dynamobim.com/t/how-to-identify-orphaned-tags/16076/5 "2018-08-04T19:38:56Z")

</div>

Just in case you haven’t found an answer… Use the “Try Get Property Value” node from Wombat to filter unorphaned elements.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/2/b2998b98fc81be94b1b6fdef74778538677ef7f1.png)

Good luck!

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [August 7, 2018, 9:16am UTC](https://forum.dynamobim.com/t/how-to-identify-orphaned-tags/16076/6 "2018-08-07T09:16:39Z")

</div>

Hi @ChrisRob,

This is a great tip, unfortunately it only works with Rooms and Spaces, as the issue which @jacob.small mentions still appears to be current…

Ie. every other kind of tag which is referencing a linked file will not be returned in the ‘all elements of category’.

Thanks again.

Mark

---

<div class="post-metadata">

**Author:** ![rlosh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/rlosh/32/31759_2.png) [@rlosh](https://forum.dynamobim.com/u/rlosh)\
**Post date:** [August 8, 2018, 2:24pm UTC](https://forum.dynamobim.com/t/how-to-identify-orphaned-tags/16076/7 "2018-08-08T14:24:15Z")

</div>

Thanks for the suggestion @ChrisRob Unfortunately, even when the tag displays a question mark, IsOrphaned is still set to “false”. I used Revit Lookup to confirm this. (See snippet below.)

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/7/7779a0f227a525c3c0e23e54dd3e317f16ad8341.png)

---

<div class="post-metadata">

**Author:** ![Konrad\_K\_Sobon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/konrad_k_sobon/32/8838_2.png) [@Konrad\_K\_Sobon](https://forum.dynamobim.com/u/Konrad_K_Sobon)\
**Post date:** [August 8, 2018, 6:25pm UTC](https://forum.dynamobim.com/t/how-to-identify-orphaned-tags/16076/8 "2018-08-08T18:25:09Z")

</div>

@rlosh yes, you are correct that the IsOrphaned property is showing false. I think this is specific to only elements from a linked model so that when you tag something from a link, and that element in a link was deleted it would change this property to `true`. This is speculation at this point as I have not tested this.

Anyways, here’s a potential approach:

![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/0/f06c66aa4f2d1f994322574e73c8fa95a8fe9b08.png)

Instead of testing the `isOrphaned` property of the tag, we can instead test its contents. if the contents are just a “?” or multiple “???” (this is possible if tag has bindings to multiple parameters. tag text will have x-number of “?” for each parameter that it could not retrieve).

This is contents of the python node that gets the is orphaned property:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/5/b5b7ee911a4e65ceed9f538c2d75d64e26564daa.png)

This is contents of the python node that gets the tag text property:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/e/eeb82b6b7c83d5cd8fbf52e7f013becb3c2543b3.png)

Good luck!

Ps. I was using Dynamo 2.0 for this, and as it happens i am on a little outdated version of the Revit, that still doesn’t allow me to copy/paste. Sorry but I could not get the code pasted.

---

<div class="post-metadata">

**Author:** ![rlosh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/rlosh/32/31759_2.png) [@rlosh](https://forum.dynamobim.com/u/rlosh)\
**Post date:** [August 8, 2018, 6:41pm UTC](https://forum.dynamobim.com/t/how-to-identify-orphaned-tags/16076/9 "2018-08-08T18:41:17Z")

</div>

@Konrad_K_Sobon Thanks for the reply. Also, (as shown on the screenshot) the TagText property is empty. Will it still evaluate correctly? Thanks again!

---

<div class="post-metadata">

**Author:** ![Konrad\_K\_Sobon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/konrad_k_sobon/32/8838_2.png) [@Konrad\_K\_Sobon](https://forum.dynamobim.com/u/Konrad_K_Sobon)\
**Post date:** [August 8, 2018, 7:02pm UTC](https://forum.dynamobim.com/t/how-to-identify-orphaned-tags/16076/10 "2018-08-08T19:02:45Z")

</div>

Well the solution that I have posted would not work for TagText property being empty. You would have to add another check. Something along the lines of: if tag text is ??? or “” then consider this tag orphaned.

Please post a sample file (minimal sample if possible) so that I can re-create. Revit 2018 is preferred.

---

<div class="post-metadata">

**Author:** ![rlosh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/rlosh/32/31759_2.png) [@rlosh](https://forum.dynamobim.com/u/rlosh)\
**Post date:** [August 10, 2018, 2:14pm UTC](https://forum.dynamobim.com/t/how-to-identify-orphaned-tags/16076/11 "2018-08-10T14:14:50Z")

</div>

@Konrad_K_Sobon Please see attached file. [Orphan Rescue.dyn](https://forum.dynamobim.com/uploads/short-url/yxuRraOEpmsgsZMb6CypAqWTL3P) (15.4 KB) For some reason I can’t get the RVT to upload. I just used the OOTB Architectural template, put in a basic exterior wall, and tagged the wall materials in a section view using the OOTB material tag.

Thanks!

---

<div class="post-metadata">

**Author:** ![Konrad\_K\_Sobon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/konrad_k_sobon/32/8838_2.png) [@Konrad\_K\_Sobon](https://forum.dynamobim.com/u/Konrad_K_Sobon)\
**Post date:** [August 10, 2018, 9:48pm UTC](https://forum.dynamobim.com/t/how-to-identify-orphaned-tags/16076/12 "2018-08-10T21:48:24Z")

</div>

I will need a Revit file. Please post a link to GDrive, Dropbox, Box etc. That’s the easiest way to share. I will need an example of a Revit file that has these orphaned tags. I don’t have any sample models that I can replicate this with.

---

<div class="post-metadata">

**Author:** ![rlosh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/rlosh/32/31759_2.png) [@rlosh](https://forum.dynamobim.com/u/rlosh)\
**Post date:** [August 20, 2018, 4:21pm UTC](https://forum.dynamobim.com/t/how-to-identify-orphaned-tags/16076/13 "2018-08-20T16:21:45Z")

</div>

@Konrad_K_Sobon Please use the link below to download the file. Sorry it has been so long - several deadlines in a row! The orphaned material tags are in the section view.

[Revit File](https://autode.sk/2nRwnmU)

Thanks!

---

<div class="post-metadata">

**Author:** ![rlosh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/rlosh/32/31759_2.png) [@rlosh](https://forum.dynamobim.com/u/rlosh)\
**Post date:** [July 10, 2019, 12:57pm UTC](https://forum.dynamobim.com/t/how-to-identify-orphaned-tags/16076/14 "2019-07-10T12:57:34Z")

</div>

Sorry to resurrect this thread, but I’m back to trying to find a solution. @Konrad_K_Sobon did you ever get a chance to look at the file? Thanks!

---

<div class="post-metadata">

**Author:** ![Konrad\_K\_Sobon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/konrad_k_sobon/32/8838_2.png) [@Konrad\_K\_Sobon](https://forum.dynamobim.com/u/Konrad_K_Sobon)\
**Post date:** [July 19, 2019, 3:29am UTC](https://forum.dynamobim.com/t/how-to-identify-orphaned-tags/16076/15 "2019-07-19T03:29:06Z")

</div>

@rlosh sorry mate, that was like a year ago. I believe that my answer was sufficient. It’s not hard to modify what I posted to include another check. You should be fine.

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [July 19, 2019, 9:32am UTC](https://forum.dynamobim.com/t/how-to-identify-orphaned-tags/16076/16 "2019-07-19T09:32:18Z")

</div>

Hey @rlosh,

So I had a look at it for you.

There’s good news & bad news.

So your Revit file is all about material tags (incidentally your file did not include any orphaned tags).

The good news is that truly orphaned tags can be identified. Though they cannot be selected through Dynamo (I believe). When you use a filtered element collector, the orphaned tags throw a ‘null’ when toElements is used, this freaks out most nodes which have been built. So I had to do my own Python to get them.

The bad news is that Material tags do not use TagText & their ‘Schema’ is not accessible. So you do not have a method of reviewing ‘?’ values as you had hoped.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/f/3fa490262e7618845b6b2176356c4eabaab0b222.png)

Instead I would suggest you get the materials used in the tagged elements & review their properties. However this won’t work on ones like this one… As it thinks it’s not orphaned and the host element has a material description in all layers.  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/c/0c61f8d36d5c2365c60e43da26171af59d459cb0.png)

Alternatively, there may be a method of printing your drawings and identifying ? as a pattern somehow in the drawing, but I don’t know how to do that.

Below is my graph and screen grab, hopefully they are of interest.

Cheers,

Mark

[Orphan Rescue-MKA.dyn](https://forum.dynamobim.com/uploads/short-url/yrsFYohY0fxcXHzbs0dfBNEzQTd.dyn) (48.5 KB)  
[New folder-MKA.rvt](https://forum.dynamobim.com/uploads/short-url/aJmKB1XJ4LJ9Y9tTNDqUalzHCLX.rvt) (1.4 MB)  
[linking.rvt](https://forum.dynamobim.com/uploads/short-url/yhtJzqU9JzpIeNnP8BEgQY47Lg5.rvt) (1.2 MB)

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/5/75b6ca74e48e6d8ae7421a076754c2c03b454fb5.png)

---

<div class="post-metadata">

**Author:** ![rlosh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/rlosh/32/31759_2.png) [@rlosh](https://forum.dynamobim.com/u/rlosh)\
**Post date:** [July 19, 2019, 3:55pm UTC](https://forum.dynamobim.com/t/how-to-identify-orphaned-tags/16076/17 "2019-07-19T15:55:00Z")

</div>

@Konrad_K_Sobon I definitely understand. I should’ve looked at the date before posting this! 😄

@Mark.Ackerley Thanks for the help! This is a very thorough and concise explanation of what is (and is not) currently possible. FWIW, once a drawing set is output to PDF we can search for the “?” to identify orphaned tags in Bluebeam. That’s our current method of identifying these instances. I will have a look at the graphs you sent. Thanks again!

---

<div class="post-metadata">

**Author:** ![Konrad\_K\_Sobon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/konrad_k_sobon/32/8838_2.png) [@Konrad\_K\_Sobon](https://forum.dynamobim.com/u/Konrad_K_Sobon)\
**Post date:** [July 19, 2019, 9:27pm UTC](https://forum.dynamobim.com/t/how-to-identify-orphaned-tags/16076/18 "2019-07-19T21:27:28Z")

</div>

@Mark.Ackerley great analysis. I didn’t realize that Material Tags don’t have the Text property. In that case I agree with you that we have to get a little bit more creative. How about a geometric approach to the problem? Each Tag has a property called BoundingBox and if it has text in the Tag, the BBox will be bigger. If there is no text, the BBox will be smaller. What’s even more important to us, is that the HeadPosition of the Tag that has no text will be very close to the edge of the Bounding box, as opposed to one that has some text in it, since text would stretch the BBox further out. Here’s my approach:

 ![orphanedTags](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/1/a15d0451ae7b619a7281e3acc81e93b4aae96737.png)

Ps. The breakdown of the geometry + distance calculations can be made a little “less nodes”, but I wanted to be really explicit.

Here’s the code for those two Python nodes:

```auto
# Copyright(c) 2019, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net

import clr
clr.AddReference('ProtoGeometry')
import Autodesk.DesignScript.Geometry

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

# Import RevitAPI
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

import System
from System import Array
from System.Collections.Generic import *

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

def process_list(_func, _list):
    return map(lambda x: process_list(_func, x) if type(x) == list else _func(x), _list)

def get_points(tag):
	e = UnwrapElement(tag)
	bb = e.get_BoundingBox(doc.ActiveView)
	a = Autodesk.DesignScript.Geometry.Point.ByCoordinates(bb.Min.Y, bb.Min.Z, bb.Min.X)
	b = Autodesk.DesignScript.Geometry.Point.ByCoordinates(bb.Max.Y, bb.Min.Z, bb.Min.X)
	c = Autodesk.DesignScript.Geometry.Point.ByCoordinates(bb.Max.Y, bb.Max.Z, bb.Max.X)
	d = Autodesk.DesignScript.Geometry.Point.ByCoordinates(bb.Min.Y, bb.Max.Z, bb.Max.X)
	return [a,b,c,d]

try:
    errorReport = None
    output = process_list(get_points, IN[0])
except:
    import traceback
    errorReport = traceback.format_exc()

if None == errorReport:
    OUT = output
else:
    OUT = errorReport

```

```auto
# Copyright(c) 2019, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net

import clr
clr.AddReference('ProtoGeometry')
import Autodesk.DesignScript.Geometry

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

import System
from System import Array
from System.Collections.Generic import *

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

def process_list(_func, _list):
    return map(lambda x: process_list(_func, x) if type(x) == list else _func(x), _list)

def get_head_position(tag):
	try:
		e = UnwrapElement(tag)
		p = e.TagHeadPosition
		return Autodesk.DesignScript.Geometry.Point.ByCoordinates(p.Y, p.Z, p.X)
	except:
		return None

try:
    errorReport = None
    output = process_list(get_head_position, IN[0])
except:
    import traceback
    errorReport = traceback.format_exc()

if None == errorReport:
    OUT = output
else:
    OUT = errorReport

```

And here’s a little preview video:

> **[Jul 19, 2019 5:26 PM.webm (video)](https://drive.google.com/file/d/141W2RI1ptxLpWkYNrCHwTVPkq5WUvDDw/view)**
>
> Google Drive file.

Finally Dynamo Definition:

[orphanedTags.dyn](https://forum.dynamobim.com/uploads/short-url/rb9XDWxCdrRbIgi7Zjgn5HbtYCm.dyn) (46.7 KB)

Ps. I had another look at the issue here, and posted a detailed solution on my blog: [http://archi-lab.net/identifying-orphaned-tags-and-dynamo-bugs/](http://archi-lab.net/identifying-orphaned-tags-and-dynamo-bugs/) That should cover all of the issues raised above.

---

<div class="post-metadata">

**Author:** ![rlosh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/rlosh/32/31759_2.png) [@rlosh](https://forum.dynamobim.com/u/rlosh)\
**Post date:** [July 22, 2019, 6:20pm UTC](https://forum.dynamobim.com/t/how-to-identify-orphaned-tags/16076/19 "2019-07-22T18:20:46Z")

</div>

@Konrad_K_Sobon This is awesome - a very inventive way of evaluating the tag’s state. Thank you!
