How to identify orphaned tags?

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/. 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!

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:

http://www.revitapidocs.com/2017/4906fa9c-e424-92e7-0b7e-15389726ca78.htm

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

http://www.revitapidocs.com/2017/8e297dee-920d-f620-6198-0bed494e3f04.htm

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

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

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

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

Good luck!

1 Like

Hi @ChrisRob,

This is a great tip, unfortunately it only works with Rooms and Spaces, as the issue which @JacobSmall 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

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.)

@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

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:

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

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.

1 Like

@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!

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.

@Konrad_K_Sobon Please see attached file. Orphan Rescue.dyn (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!

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.

@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

Thanks!

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!

@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.

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.

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

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 (48.5 KB)
New folder-MKA.rvt (1.4 MB)
linking.rvt (1.2 MB)

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

@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!

@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:

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:

# 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
# 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:

Finally Dynamo Definition:

orphanedTags.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/ That should cover all of the issues raised above.

6 Likes

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