Is there a way to get a tags bounding box?
Thanks for any help you can provide,
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.
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) view = UnwrapElement(IN) list =  for i in tag: bbox = (i.BoundingBox[view]) pt = (bbox.Min,bbox.Max) list.append(pt) TransactionManager.Instance.TransactionTaskDone() OUT = list
What kind of tags are you working with?
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?
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.
Here is the python for it:
#Copyright(c) 2017, john pierson # @60secondrevit, http://sixtysecondrevit.com 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) #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.
That being said, I bet you could make a custom bounding box and intersect them against your rooms or something.
So this graph:
Would result in this.
Since I did not know the filtering you were using, I just filtered rooms out that started with “12” in the number.
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 if it cannot exquisite TagHeadPosition?
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.