Trying to Get the BoundingBox Property but getting ReflectedIndexer

Hey Everyone,

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!

A similar topic as yours already exists:

And a possible solution would be:

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

clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

def tolist(obj1):
    if hasattr(obj1,"__iter__"): return obj1
    else: return [obj1]

def GetBB(tblks):
	BBoxArr = []	
	for tbs in tblks:
		bbox = tbs.get_BoundingBox(doc.ActiveView).ToProtoType()
		BBoxArr.append(bbox)
	return BBoxArr

TBlocks = tolist(UnwrapElement(IN[0]))
	
OUT = GetBB(TBlocks)
2 Likes

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

image


@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:

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

which you didn’t and hence the error.

Please try using the code shared with you and see if it works.

If it doesn’t, then other possible reason is that one or more of your sheets don’t have a title block on it.

2 Likes

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.

2 Likes

@GavinCrump I’m passing through the title block instances I got from each sheet. And the Element.BoundingBox Node doesn’t seem to like it

@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

To note that’s a tip that usually works for a titleblock’s type to see where it’s default placement is, not for instances.

Having said that, maybe it can be used…

@shuzmm I see what’s the issue here. We need to change the views in the loop.

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

clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

def tolist(obj1):
    if hasattr(obj1,"__iter__"): return obj1
    else: return [obj1]

def GetBB(tblks,vws):
	BBoxArr = []	
	for tbs,vw in zip(tblks,vws):
		bbox = tbs.get_BoundingBox(vw).ToProtoType()
		BBoxArr.append(bbox)
	return BBoxArr

TBlocks = tolist(UnwrapElement(IN[0]))
views = tolist(UnwrapElement(IN[1]))
OUT = GetBB(TBlocks,views)
1 Like

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??

1 Like

Hi,

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.

4 Likes

Yup, you got it right!

Ah that makes so much more sense now. Thank you!!

@shuzmm If you are learning Python then take a look into @Alban_de_Chasteigner’s Genius Loci nodes. He has done some pretty amazing stuff in there.

4 Likes

Yeah sweet I’ll definitely look into that.