How to get All Annotation Elements In Active View - section marks, elevation tags etc


#1

How to get All Annotation Elements In Active View?

The node, All Elements in Active View does not include annotation elements.

Thanks,
Moses


#2

Clockwork package has a node “All View-Dependent Family Instances Of Category”


#3

It works on text notes in a view but it doesnt work on Elevation Marks or Elevations


#4

@mscottM6C4C Oops, sorry I hadn’t tested for those elements when I suggested that node… Funny I was just about to post a Python script I wrote because I couldn’t find anything that would do what you were asking on this post and I was curious enough: Use dynamo to find all “Referring Views” - trying to reference all annotation symbols that generates a particular view

The script for that turned out to be easily modifiable to collect elevation markers along with view items like elevations and sections:

Python script:

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

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

views = UnwrapElement(IN[0])
if not isinstance(views,list):
	views = [views]

def getRefs(sheetviews):
	elevMarks = []
	viewers = []
	for view in sheetviews:
		elevMarks.append(FilteredElementCollector(doc, view.Id).OfClass(ElevationMarker).ToElements())
		viewers.append(FilteredElementCollector(doc, view.Id).OfCategory(BuiltInCategory.OST_Viewers).ToElements())
	return elevMarks, viewers
	

OUT = getRefs(views)

Let me know if that works as you expect


#5

Hi @mscottM6C4C

Here is some modification of @awilliams code which will handle lists of views and one view:

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

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument


views = []
if isinstance(IN[0],list):
	for i in IN[0]:
		views.append(UnwrapElement(i))
else: 
	views.append(UnwrapElement(IN[0]))


elevMarks, viewers = [], []
for v in views:
	elevMarks.append(FilteredElementCollector(doc,v.Id).OfClass(ElevationMarker).ToElements())
	viewers.append(FilteredElementCollector(doc, v.Id).OfCategory(BuiltInCategory.OST_Viewers).ToElements())
		

OUT = zip(elevMarks, viewers)

#6

Thanks. This works well to get the elevation markers in one list. I could just augment to code to include section marks found in the view?


#7

Thanks very much.


#8

This line here is collecting section views and the elevation pointers: viewers.append(FilteredElementCollector(doc, v.Id).OfCategory(BuiltInCategory.OST_Viewers).ToElements())

Hooking the output of the Python script to an Element.Name node should make this more apparent :slight_smile: