Bounding Box not reporting correct coordinates


#1

I’m running into an issue where I can’t get the right min and max coordinates in Dynamo. I’m using a Python script such as the following:

for element in elements:
    bbox = element.BoundingBox[doc.GetElement(element.OwnerViewId)]
				
min = bbox.Min
max = bbox.Max

Whenever I use this same code in Revit Python Shell, I get two different numbers for the min and the max.
For example: In Dynamo I get (-2.2, 93, 0) and in RPS I get (-32.2, 93, 0)

Any reason for the discrepancy?

I feel like I am missing some sort of conversion in Dynamo? Has anyone else seen this issue?

Thanks,
Dan


#2

My guess: Units.

What value do you get from the OOTB bounding box method?


#3

Revit Python Shell: (33.131, -72.270, 0)
Dynamo Python: (53.357, -111.017, 0)
Dynamo OOTB Node: (53.857, -107.986, 0)

See attached image for script and nodes.

Not sure what’s causing the inconsistencies. Any ideas?


#4

Can you share a model and the dyn?


#5

Here is a super simple Revit file with a group on the Drafting View that I am using to try to test the bounding box as well as the dynamo file above.

Let me know if you can figure it out.

Thanks!

BoundingBox.dyn (4.0 KB)
BoundingBox.rvt (700 KB)


#6

Anyone have any other insights into this? I’d love to get this to work.


#7

I dont have Revit available. Is the object aligned with xy axis, or rotated at some angle not divisible by 90?

I don’t think aligned bounding boxes are currently possible.


#8

The object is a detail group made up of detail lines that are drawn at different angles, so not all of the components of the detail group are aligned with the x-y axis.

The weird part is that the Revit Python Shell portion actually reports the correct coordinates and what I am looking for, so I figured it was some Dynamo conversion I was missing or something.


#9

My inclination is thats its possibly something to do with the Bounding boxes transform property.

It might be that one environment is reporting the min/max points relative to the global coordinate space, and another is reporting it relative to the bounding boxes transform.

Keep in mind that 2D views have a ‘facing’ direction along the Z-axis and the object you are querying (i.e. a detail group) only resides in these views, so maybe its bounding box is using the same transform as the view, and this transform is not the same to the global CS hence the discrepancy. Just a guess, but a simple test would be to get the min/max points in dynamo using the OOTB nodes, then write a simple python script which gets the min/max points transformed by the transform of the BB and see if they align or report the different coordinates you’ve observed.


#10

Thomas,

Thank you for taking a look at this. Unfortunately, I am not very familiar with Transforms and how they apply to elements in this situation. Do you have any references that I can check to get me up to speed on how to get an element’s Transform?

Thanks!

Edit: Your suggestion sent me in the right direction at least. I see there is a Transform property to the Bounding Box, and I was able to use Transform.OfPoint(box.Min) that gave me the right number. Seems like you were right in that the Transform of the coordinate system wasn’t the same.

Thank you! I’m always interested in learning more about the Revit API, so if you have any references that helped you understand the transform, please send them my way!


#11

No problem, it was just a passing thought to be honest! I’m not aware of any references you can look at, however the transform property of a bounding box is primarily needed for defining volumetric clips in views- like section boxes - free from the constraints that come with bounding boxes, so you could maybe look into how this works for reference.

Seems like you cracked it in any case - I was referring to the OfPoint method so you did what I would have done. :+1: