Python - BoundingBox property returns indexer. How to get Element.BoundingBox?

I am trying to get the bounding box of an element so I can get the middle point.

I thought this would be the Element Property

Using this on a Room Element, python returns a
IronPyton.Runtime.Types.ReflectedIndexer
from which I can get the Max or Min points.

import clr

# import Revit Services 
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

# import Revit API
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
rooms=FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).ToElements()
bbox = rooms[0].BoundingBox

#bbMax=bbox.Max

OUT=bbox

This post on stackoverflow includes a function get_BoundingBox, which is not in the Revit API library. I have not seen an ‘_’ used in function names so suspect this is part of pyRevit?.

el_bb = el_ID.get_BoundingBox(doc.ActiveView)

I would like to be able to get the bounding box of the element using Python.

Thank you.

Does the get_BoundingBox() not work? I believe that Syntax is correct for python.

Thanks Sean, I managed to get get_BoundingBox to work:

def GetCenterPoint(ele):
	bBox = ele.get_BoundingBox(None)
	return (bBox.Max + bBox.Min) / 2

I was using the function in a larger script… I think my issue is related to this post:

Where can I find documentation on the python Syntax for the API?.

1 Like