I’m just writing a simple script to try and get the bounding box of the titleblock instance and I didn’t think it would be this hard. I’m getting the weird error “IronPython.Runtime.Types.ReflectedIndexer” when I try to extract the boundingbox property of the TitleBlock Instance.
Really not sure where to go from here, I can’t seem to find anything else on the documentation
import sys
import clr
clr.AddReference('ProtoGeometry')
clr.AddReference("RevitAPI")
clr.AddReference("RevitServices")
from Autodesk.Revit.DB import *
from Autodesk.DesignScript.Geometry import *
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
# The inputs to this node will be stored as a list in the IN variables.
# Place your code below this line
############################# Definitions ##############################
def tolist(obj1):
if hasattr(obj1,"__iter__"): return obj1
else: return [obj1]
def GetCentroid(tblks):
BBoxCen = []
BBoxArr = []
for tbs in tblks:
bbox = tbs.BoundingBox
#bboxC = (bbox.Min+bbox.Max)/2
#BBoxCen.append(bboxC)
BBoxArr.append(bbox)
return BBoxArr
########################## Input Variables ##############################
TBlocks = tolist(UnwrapElement(IN[0]))
########################## Output Variables ##############################
################################ Code #######__get__()#####################
Out = GetCentroid(TBlocks)
OUT = Out[0]
# Assign your output to the OUT variable.
Hi @shuzmm,
Welcome to the Dynamo Community.
I would recommend you always search the forum first. What you are searching for would probably be answered in some or the other way if you dig a little deeper!
Hey @AmolShah
Thanks for the reply and the quick solution!
I did also try the method in that thread. Unfortunately it’s not working either.
I wonder if it has anything to do with the element I’m passing through?
But as far as I know TitleBlock Family Instances does have a BoundingBoxXYZ property
@shuzmm It might not be working because you didn’t pay close attention to my code!
You just copied the get_BoundingBox(doc.ActiveView).ToProtoType()
But in order to use ToProtoType() you need to call:
Interesting thing to add that the OP/general people might not know. By default the type of a titleblock returns a boundingbox also, even when not placed. I use this method to detect when a titleblock isn’t sitting in its default location on a sheet, or to compare titleblocks to each other when their placement point isn’t consistent to form a translation vector.
@AmolShah Ahhh right I did miss that part. But it seems to still be giving me the same error despite importing the additional extensions. And there’s no null items in this list
Am I correct in understanding it needs the “View” which is actually referring to the sheet? And then it finds out where the title block is placed in said “View”
So Revit is actually treating the Sheet as a View??
You coule use the Annotation BoundingBox node in the Genius Loci package if you don’t want to provide sheets as inputs or use the ElementTypes of the Titleblocks.