Python get_BoundingBox returns null

I’m using python to place a family instance on a point and trying to get its bounding box using get_BoundingBox(None) method. But BoundingBox for the Instance returns Null (as shown in A). Then I tried to use the same family instance to create bounding box in separate python script using same boundingbox method it works

what am I doing wrong in Script A?

here is my code

Version:0.9 StartHTML:00000097 EndHTML:00004693 StartFragment:00000199 EndFragment:00004655 import clr
from Autodesk.DesignScript.Geometry import *

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

from Autodesk.Revit.DB import *

import Revit ,Autodesk


import DSCore
from DSCore import *

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
import os
import shutil
import math

from math import *

from datetime import datetime
now =

import System
from System.Collections.Generic import *
from System.IO import Directory, Path

famType = UnwrapElement(IN[0])

doc = DocumentManager.Instance.CurrentDBDocument


famInstance = doc.Create.NewFamilyInstance(XYZ(0,0,0) , famType , Structure.StructuralType.NonStructural)

bbox = famInstance.get_BoundingBox(None)


OUT = famInstance , bbox

The element was just created and the document has not yet been regenerated (this will happen after the TransactionTaskDone() method is executed). If you move your bbox variable outside of the transaction you should be able to get the bounding box.

Thanks for reply
I tried it still boundingbox returns null

If you want to have it all in a single script I think that you´ll have to use a revit Databse transaction, not the transaction manager

you´ll need to import
from Autodesk.Revit.DB import Transaction

and define
tran = Transaction(doc, ‘Name’)

and then use tran.Start() and tran.Commit() instead of transactionmanager.insureTransaction and TaskIsDone


it Worked! :smiley:
thank you for helping me

Another solution to have to BoundingBox of a certain instance is by using the Element Class property .BoundingBox

What if he entered the get_BoundingBox before TransactionTaskDone? Could you please explain what exactly the difference between TransactionManager und Transaction from Database?

Thanks a lot!

Edit: I see that he had done at the beggining like that and output was not correct.

The Transaction Manager is sort of a layer over the revit transactions. Here´s a few more words about it that explain it better than I can:

I guess in this example you could have used TransactionManager.ForceCloseTransaction() instead ot tran.commit(), but personally i never think about it :smiley:


Thanks a lot! :slight_smile: