Different values between Dynamo Node and Python BoundingBox

Hello people!

So I was trying to create a BoundingBox and get its min, max and center point with a python node, but I get different values than with a Dynamo Node.

Does anyone know why? Are these two based on two different coordinate systems?

I tought maybe there was a Problem with the Units conversion in Python, so I tried using the UnitUtils method but that was not it…

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference("System")
from System.Collections.Generic import List

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

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

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

doc = DocumentManager.Instance.CurrentDBDocument
UIunit = Document.GetUnits(doc).GetFormatOptions(UnitType.UT_Length).DisplayUnits
# Die Eingaben für diesen Block werden in Form einer Liste in den IN-Variablen gespeichert.
dataEnteringNode = IN

elements = UnwrapElement(IN[0])
# Code unterhalb dieser Linie platzieren
elem_box = []
mins = []
max = []
centre = []

for item in elements:
	elem_box.append(item.get_BoundingBox(None))

for item in elem_box:
	mins.append(item.Min.Z)

# Weisen Sie Ihre Ausgabe der OUT-Variablen zu.
OUT = mins

Revit internal units (the only thing you can use as a developer when making Revit API calls) are decimal feet. Dynamo uses whichever your display units are in your active Revit document and therein lies the answer. ‘Display units’ and ‘internal units’ have distinct meanings in relation to the Revit API.

3 Likes

Thanks for the answer. I suspected that may be the case and tried it before already but got strange values. But thats because I used the wrong mehtod. Namely I used the “ConvertToInternalUnits” instead of “ConvertFromInternalUnits”.

Anyways for future reference, this works:

UIunit = Document.GetUnits(doc).GetFormatOptions(UnitType.UT_Length).DisplayUnits
elements = UnwrapElement(IN[0])
# Code unterhalb dieser Linie platzieren
elem_box = []
mins = []
max = []
centre = []

for item in elements:
	elem_box.append(item.get_BoundingBox(None))

for item in elem_box:
	mins.append(item.Min.Z)

# Weisen Sie Ihre Ausgabe der OUT-Variablen zu.

OUT = [UnitUtils.ConvertFromInternalUnits(item,UIunit) for item in mins]