Filtering tag in a view that are attach to a link file element

i’m trying to sort tag based on the fact that they are tagging a linked element.
I can get all the tags of course but looking for a way to sort linked host or not

Hi Daniel,

To obtain the the tagged dElement there is the Tag TaggedElement node in Genius Loci package.
But knowing the linked host could be more difficult.

here an example

import clr
import sys
import System
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS

import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

import Revit

def IsLinkTag(t):
	if isinstance(t, SpatialElementTag):
		return t.IsTaggingLink 
		localElem = doc.GetElement(t.TaggedLocalElementId)
		locallnkElem = doc.GetElement(t.TaggedElementId.LinkInstanceId  )
		return localElem is None and isinstance(locallnkElem, RevitLinkInstance)

wrappers = clr.GetClrType(Revit.Elements.ElementWrapper).GetMethods()
for w in wrappers:
	if w.ToString().startswith("Revit.Elements.UnknownElement"):
		ueWrapper = w
toList = lambda x : x if hasattr(x, '__iter__') else [x]

lstTags = toList(UnwrapElement(IN[0]))

localTagElem = [ueWrapper.Invoke(None, (t, False)) for t in lstTags if not IsLinkTag(t)]
linkTagLinkElem = [ueWrapper.Invoke(None, (t, False)) for t in lstTags if  IsLinkTag(t)]

OUT = localTagElem, linkTagLinkElem

This works for independant tag but Is TaggingLink seems to be appropriate for spatial element tag no?

yes, i edit my previous post with this case

deee… needed a flatten list ahahahah
brilliant, thanks a lot

1 Like