# Bounding Box of Tag

**URL:** <https://forum.dynamobim.com/t/bounding-box-of-tag/19138>\
**Category:** Uncategorized\
**Created:** [February 16, 2018, 1:43am UTC](https://forum.dynamobim.com/t/bounding-box-of-tag/19138 "2018-02-16T01:43:00Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/steven/32/112504_2.png) [@Steven](https://forum.dynamobim.com/u/Steven)\
**Post date:** [February 16, 2018, 1:43am UTC](https://forum.dynamobim.com/t/bounding-box-of-tag/19138/1 "2018-02-16T01:43:00Z")

</div>

Is there a way to get a tags bounding box?

Thanks for any help you can provide,

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/d/cd1227a59af2a645c4cbab03742a626326f7eeb5.png)

---

<div class="post-metadata">

**Author:** ![Steven](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/steven/32/112504_2.png) [@Steven](https://forum.dynamobim.com/u/Steven)\
**Post date:** [February 16, 2018, 5:49pm UTC](https://forum.dynamobim.com/t/bounding-box-of-tag/19138/2 "2018-02-16T17:49:45Z")

</div>

Figured out a really bad way of doing it but I guess it works.

If you have a better way of doing this I am all ears. This really slows down my computer.

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/1/e1d1ab27e8434efe0cc78db2b085d332862f5c87.png)

```
import clr
import math

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

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

tag = UnwrapElement(IN[0])
view = UnwrapElement(IN[1])
list = []
	
for i in tag:

	bbox = (i.BoundingBox[view])
	pt = (bbox.Min,bbox.Max)
	list.append(pt)
	
TransactionManager.Instance.TransactionTaskDone()

OUT = list
```

---

<div class="post-metadata">

**Author:** ![john\_pierson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/john_pierson/32/191977_2.png) [@john\_pierson](https://forum.dynamobim.com/u/john_pierson)\
**Post date:** [February 16, 2018, 7:38pm UTC](https://forum.dynamobim.com/t/bounding-box-of-tag/19138/3 "2018-02-16T19:38:29Z")

</div>

What kind of tags are you working with?

---

<div class="post-metadata">

**Author:** ![Steven](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/steven/32/112504_2.png) [@Steven](https://forum.dynamobim.com/u/Steven)\
**Post date:** [February 20, 2018, 6:02pm UTC](https://forum.dynamobim.com/t/bounding-box-of-tag/19138/4 "2018-02-20T18:02:14Z")

</div>

Someone went through and hit tag all doors and walls in our overall plans. We have unites and do not want everyone to show these tags as they are called out on the enlarged typical unit plan. We do however want all door and wall tags outside the units. My goal was to delete all door and wall inside the units and leave all others.

I tried _Elements in Room_ from Archi-lab but it errs out saying “‘Location’ object has not attribute”.

_Room.IsInsideRoom_ will take a point but _Element.BoundingBox_ returns null and _Element.Geometry_ Empty List. This is why I wrote the code above because I can get the Revit BBox min and max points. The section after where I reassemble the points was because my lack of python and the time crunch I was in. It’s not pretty but it worked.

Do you have any suggestions @john_pierson?

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/a/1ae0a5b6821db318166724e42111dcb76322dd49.PNG)

---

<div class="post-metadata">

**Author:** ![john\_pierson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/john_pierson/32/191977_2.png) [@john\_pierson](https://forum.dynamobim.com/u/john_pierson)\
**Post date:** [February 20, 2018, 9:33pm UTC](https://forum.dynamobim.com/t/bounding-box-of-tag/19138/5 "2018-02-20T21:33:26Z")

</div>

Yeah, I thought about it a bit and it seems like you can use the following method to find where the tag resides in the model.

> **[TagHeadPosition Property](https://www.revitapidocs.com/2018.1/4f49d3f3-e5c5-108a-49dd-2a36697bd08e.htm)**
>
> Online Documentation for Autodesk's Revit API: 2015, 2016, 2017, 2017.1, 2018

Here is the python for it:

```
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

from System.Collections.Generic import *

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk

#unwrap all elements to use with API
tags = UnwrapElement(IN[0])
#apply lineweight override to elements in an input list
tagHeadPosition = list()
for i in tags:
	try:
		tagHeadPosition.append(i.TagHeadPosition.ToPoint())
	except:
		tagHeadPosition.append(list())

#Assign your output to the OUT variable
OUT = tagHeadPosition

```

This could prove to not work on door tags “inside” the wall though.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/e/0e3c7e5b8d29e794ba580e09a4c418583741c372.png)

That being said, I bet you could make a custom bounding box and intersect them against your rooms or something.

So this graph:

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/4/b43046c223973db6f993fc0adf30db3b06023c7c.png)  
[20180220-tagsIntersectingRoom.dyn](https://forum.dynamobim.com/uploads/short-url/2NElSECtQ5sCU7Ckh7m5Y8HBqpx.dyn) (25.0 KB)

Would result in this.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/b/bb30ac0a9e00393256fde0f9a47c992826920a68.png)

Since I did not know the filtering you were using, I just filtered rooms out that started with “12” in the number.

-john

---

<div class="post-metadata">

**Author:** ![Steven](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/steven/32/112504_2.png) [@Steven](https://forum.dynamobim.com/u/Steven)\
**Post date:** [February 20, 2018, 10:30pm UTC](https://forum.dynamobim.com/t/bounding-box-of-tag/19138/6 "2018-02-20T22:30:17Z")

</div>

Thanks John,

Really helpful post and thanks for the python code as well. Since I am starting to learn code its helpful to see how to complete an idea.

Quick question: Is “try:” the task to get the head point and then “except:” will return the tag IN[0] if it cannot exquisite _TagHeadPosition_?

Thanks,  
Steven

---

<div class="post-metadata">

**Author:** ![john\_pierson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/john_pierson/32/191977_2.png) [@john\_pierson](https://forum.dynamobim.com/u/john_pierson)\
**Post date:** [February 20, 2018, 10:31pm UTC](https://forum.dynamobim.com/t/bounding-box-of-tag/19138/7 "2018-02-20T22:31:20Z")

</div>

Yeah, what that will end up doing is outputting an empty list to filter against.

I actually picked up on this technique from @Andreas_Dieckmann’s awesome clockwork package. 🙂

---

<div class="post-metadata">

**Author:** ![sandeep.kumawat](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@sandeep.kumawat](https://forum.dynamobim.com/u/sandeep.kumawat)\
**Post date:** [October 21, 2022, 12:27pm UTC](https://forum.dynamobim.com/t/bounding-box-of-tag/19138/8 "2022-10-21T12:27:11Z")

</div>

```auto
for i in tag:
    a=i.OwnerViewId
    view=doc.GetElement(a)
    bbox = (i.BoundingBox[view])

```

This code Showing Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.  
unexpected indent

How can i fix it.

---

<div class="post-metadata">

**Author:** ![sandeep.kumawat](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@sandeep.kumawat](https://forum.dynamobim.com/u/sandeep.kumawat)\
**Post date:** [October 27, 2022, 8:41am UTC](https://forum.dynamobim.com/t/bounding-box-of-tag/19138/9 "2022-10-27T08:41:49Z")

</div>

Mechanical Equipment Tags  
i have tags from multiple views and i want to get bounding box of them

---

<div class="post-metadata">

**Author:** ![jw.vanasselt](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jw.vanasselt/32/133533_2.png) [@jw.vanasselt](https://forum.dynamobim.com/u/jw.vanasselt)\
**Post date:** [October 27, 2022, 9:30am UTC](https://forum.dynamobim.com/t/bounding-box-of-tag/19138/10 "2022-10-27T09:30:49Z")

</div>

@sandeep.kumawat  
Geniusloci has it inside his package 😉  
Try this:

> <https://github.com/albandechasteigner/GeniusLociForDynamo/blob/master/Nodes/Annotation%20BoundingBox.dyf#L13-L56>

---

<div class="post-metadata">

**Author:** ![sandeep.kumawat](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@sandeep.kumawat](https://forum.dynamobim.com/u/sandeep.kumawat)\
**Post date:** [October 27, 2022, 12:00pm UTC](https://forum.dynamobim.com/t/bounding-box-of-tag/19138/11 "2022-10-27T12:00:33Z")

</div>

Thanks for sharing  
But using this making dynamo Crash  
It runs only for single time.  
If i am using bounding box minimum and maximum point to make a cuboid than it is giving error :

Warning: BoundingBox.ToCuboid operation failed.  
Unable to create block : ACIS\_EXCEPTION\_ACCESS\_VIOLATION – Access violation

---

<div class="post-metadata">

**Author:** ![peerawit.ru](https://avatars.discourse-cdn.com/v4/letter/p/77aa72/32.png) [@peerawit.ru](https://forum.dynamobim.com/u/peerawit.ru)\
**Post date:** [January 16, 2024, 9:25am UTC](https://forum.dynamobim.com/t/bounding-box-of-tag/19138/12 "2024-01-16T09:25:00Z")

</div>

HI Steven.  
I have a question.  
If I want to get only tag text bounding box exclude tag leader what must I do?  
I try to set tag hide leader and get bounding box and show leader back but data is include leader.  
Thankyou.

---

<div class="post-metadata">

**Author:** ![Steven](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/steven/32/112504_2.png) [@Steven](https://forum.dynamobim.com/u/Steven)\
**Post date:** [January 16, 2024, 9:11pm UTC](https://forum.dynamobim.com/t/bounding-box-of-tag/19138/13 "2024-01-16T21:11:54Z")

</div>

I would have to specifically look at your family but I would say no this will not get you what you want. The bounding box will get you a box around the whole family not just text. If you want the bounding box for just the text I would recommend figuring out the min/max points within the family relative to the insertion point. Once placed in the file, you can get the tag’s insertion point and do the math backward.

In any case, I would recommend giving something a try and starting a new post.

---

<div class="post-metadata">

**Author:** ![Kai](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Kai](https://forum.dynamobim.com/u/Kai)\
**Post date:** [January 16, 2024, 11:28pm UTC](https://forum.dynamobim.com/t/bounding-box-of-tag/19138/14 "2024-01-16T23:28:07Z")

</div>

Morning @peerawit.ru  
have a look at @sovitek post here, it may be of use.

> [@Annotation Bounding box](https://forum.dynamobim.com/t/annotation-bounding-box/33938/13):
>
> 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
