Annotation Bounding box

Hi all,
is it possible to get an annotation “bounding box”?

Yep, but you need to use Python and call the BoundingBox[view] property accessor yourself as the OOTB nodes fail (they pass null as the view input which is fine for elements not restricted to views, but invalid for elements which are…such as annotations).

1 Like

Hi Thomas,

When I get the bounding box, it comes in as a ReflectedIndexer & I can’t get useful information out of it… Would you mind helping?

Thanks :slight_smile:

Mark
image
image

As @Thomas_Mahon said, you would need to pass a view. The syntax is different than a method where you pass arguments using (), instead you would use [] .

So for yours to work, you need to either add a view input or get the owner view and pass that as the argument like this: bbox.append(t.BoundingBox[view].Min)

This is my example:

# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitNodes')
import Revit
# Import DocumentManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.ImportExtensions(Revit.GeometryConversion)

def isInstance(check):
    if isinstance(check, list): return check
    else: return [check]

text = isInstance(IN[0])
text = UnwrapElement(text)

bbox = []
bboxMin = []
bboxMax= []

for t in text:
    viewId = t.OwnerViewId
    view = doc.GetElement(viewId)
    bbox.append(t.BoundingBox[view])
    bboxMin.append(t.BoundingBox[view].Min)

OUT = bbox, bboxMin

textboundingbox

3 Likes

Thanks Kenny,

I would never have worked that out!

Now that you say it, I can see how it’s noted in the documentation :slight_smile: & I properly understand Thomas’ response.

I just changed it to bbox.append(t.BoundingBox[view].ToProtoType()) to get a Dynamo usable output…

Cheers,

Mark

4 Likes