Select annotations by associated revit id of modelled element

Could someone please help advise if i can select annotative elements based on the revit id’s of the associated modelled elements.

I am hoping to select model elements to get a list of revit ids.

Then select all annotations and filter by associated revit object id - to select annotations which relate to the group of objects selected above.

I have tried looking at list of parameters within dimensions which had no reference to related revit id (I was surprised at the relative lack of information available with these)

When trying to select all elements of category … selecting material tags , i receive an error “ElementQueries.OfCategoryoperation failed. . an internal error has occurred”

Any thoughts anyone?

Also the object model (although horribly outdated) - is there a semi legible high resolution version in existence

I will try install visual studio this eve and investigate that way.

Many thanks

J-P

Related revit ids.dyn (27.9 KB)

Here are my current fumblings

Hi @jup ,
for tags there’s a node in the archi-lab package :

for dimensions, I don’t know of any existing node that retrieves the reference elementd. So here’s some code :

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import*
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
import sys
pyt_path = r'C:\\Program Files (x86)\\IronPython 2.7\\Lib'
sys.path.append(pyt_path)

doc = DocumentManager.Instance.CurrentDBDocument
def ProcessList(_func, _list):
    return map( lambda x:
    process_list(_func, x) if type(x)==list else _func(x), _list )

def GetDimensionHostElement(dimension):

	hostElemRefs = UnwrapElement(dimension).References
	hostElems = [doc.GetElement(he.ElementId) for he in hostElemRefs]
	return hostElems

try:
	errorReport = None
	output = ProcessList(GetDimensionHostElement, IN[0])
except:
	# if error accurs anywhere in the process catch it
	import traceback
	output = traceback.format_exc()

OUT = output
3 Likes

Thank you Mostafa,

Your code has worked pretty well. But this was asked semi quickly in the midst of a massive issue.

I have asked the question again with better context of the issue at hand (mostly to assess the feasibility of whether this is even worth pursuing - see Moving part of model + annotations)

in short though your code did work perfectly well, so well done.

I’ve always wondered where everyone finds modules and classes for these python scripts. I was recently told the magic words of object model (which i’d never heard of before … and seems visual studio can open this up but i’ve yet to investigate).

Any advice on cracking python for dynamo … i did used to use python for rhino which was very transparent with amazing help with classes and modules and return values etc … but with revit is seems about as opaque as a gallon of crude