Unable to get BoundingBox from FamilyInstance (python)

Hello,
I take references that I find with the ReferenceIntersector, then I find the element ID and try to obtain the BoundingBox Min/Max points.
But apparently I can’t get the BoundingBox from the FamilyInstance, and I need to somehow convert it to the actual Element object.

for ref in referenceWithContext:
	e = doc.GetElement(ref.GetReference()) # get the element
	print(e.Id) # prints correctly
	bbox = e.BoundingBox
	print(bbox) # prints <indexer# object at 0x0000000000000241>

I’ve found this but it didn’t offer a lot of help:

Any ideas on how to get the bbox from the element?

You can use Package DynaMEP

Hi,
Thanks, but I’m using Python in pyRevit so I’m not using Dynamo at all. I need a solution in native Python.

import clr
e = UnwrapElement(IN[0])
view = UnwrapElement(IN[1])
output = [ ]
bb = e.BoundingBox[view]
OUT = [bb.Min,bb.Max]

Hi,
Try to use the method .get_BoundingBox(None)

Where None is representing the view from which to get the bounding box. With None it just return the normal bb in the 3d space.

1 Like

Hi, thanks @Giuseppe_Dotto that was it!
It seems very hard to figure out Python syntax for Revit API C# methods sometimes…

For example, another syntax that I can’t figure out is how to create a NewPlane(XYZ,XYZ) in Python. Is there some way to know how to define these things?

Hi @AH_Yafim ,
I know that at the beginning might seem a little bit difficult to understand how to diving in the API but after a while, and looking at the right references and forums, everything will be more affordable.

About your example, the Plane is another Revit API class. To create them you can use this method:
https://apidocs.co/apps/revit/2020/ab735815-f6bc-aae1-8afc-8505bba18cb5.htm
where the second XYZ, if for example, you are looking for a horizontal plane, will be XYZ(0,0,1)

1 Like

Thanks,
Sometimes the Revit API Docs are slightly different than the ApiDocs.co.
I was referring to the Python implementation, which doesn’t always work as in the case for the .get_BoundingBox(None) solution.

:slight_smile: