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

Hi,
I’m trying to use @Alban_de_Chasteigner 's genius loci package for the same, but looks like it is giving points which are quite far (min and max).

Any thoughts?

Regards,
Atharva Purohit

Hi @atharva.purohit466SX
Seem close to me have you tested in your view?


Cheers,
KS

1 Like

Hi Kai,

Thanks for replying, let me try it out.
Btw, why did you use geometry.translate?

Regards,
ap

Hi I tried it,

it is giving till leader and at some point on the tag, I wanted bounding box for just text part, looks like it is not possible.

Hi @atharva.purohit466SX …here is a dirty idea :wink: , but could probably help… I try to on/off the leader as here…

1 Like

Hi Soren,

Haha! Actually I also thought of it previously, but you know when i’ll again turn the leader on it wont be same as I made it earlier, so it will be more work yk!

What I wanted here was to create a underline below the text in my tag, which is as a parameter.
So to compute the length of the line I was trying to get bounding box. Another thing I thought was to fetch the length of the string by counting and then multiplying it by some factor, but you know, not all character would have same width. For instance, “I” and “O” would have different width.
If anyone have any idea, please let me know!

Regards,
ap

1 Like

are you sure…in my case it always jump to the right place again…

LJUH7iHmUr

EDIT think now what you mean :wink: :wink: you mean if you have elbow on your leader…then something…sorry :wink:

2 Likes

Hah yes sir!
But looks like I solved it and it is working.
Counted the string characters and multiplied it by 2.1 as multiplication factor.
(For 2.5mm arial)

:slight_smile:

2 Likes