Getting BoundingBoxXYZ of element relative to specific view

Getting BoundingBoxXYZ of element relative to specific view

Anonymous
Not applicable
3,313 Views
3 Replies
Message 1 of 4

Getting BoundingBoxXYZ of element relative to specific view

Anonymous
Not applicable

Hello,

 

I am trying to get the BoundingBoxXYZ of an element as it is viewed within a section view. I thought I had it nailed down using the following procedure, but I am now seeing that it is only working if the element & section view are aligned orthographically. Here is my code:

 

 

BoundingBoxXYZ viewBB = view.get_BoundingBox(view); // view = the ViewSection

BoundingBoxXYZ elemBB = element.get_BoundingBox(doc.ActiveView);



XYZ xfMin = viewBB.Transform.Inverse.OfPoint(elemBB.Min);
XYZ xfMax = viewBB.Transform.Inverse.OfPoint(elemBB.Max);

If I run this code on an element & section that are aligned orthographically, the Min/Max values are correct according to the ViewSection's orientation.

Example:

For a rectangular box 2ft wide x 3ft tall x 1ft Tall

The BoundingBox Min/Max is reported as :

(-1.159410750, -49.417618267, 0.000000000)
(0.840589250, -47.917618267, -3.000000000)

 

If I run this code on the same element & section but rotated at a 45-degree angle, the Min/Max values as follows:
(-0.078885239, -49.417618267, 1.500000000)
(-0.078885239, -47.917618267, -3.500000000)

At first, I thought that the boundingbox being reported was still the size as if I were to analyze the bounding box in plan view. i.e. a rotated element's BoundingBox is going to be much larger than that of an element's BoundingBox that is completely aligned with the view's vertical and horizontal lines. 

But if you look at the individual differences between the Max and Min X, Y, Z values it seems that the coordinates get re-arranged. For example, the Z coordinate of the the 45-dgree BoundingBox is now 2ft. Where 2ft should be the X dimension. Am I missing something simple here? Perhaps misuse, or not using the correct transform when I am getting the coordinates? 

 

Thanks

 

 

0 Likes
3,314 Views
3 Replies
Replies (3)
Message 2 of 4

jeremytammik
Autodesk
Autodesk

Dear Pat,

 

I think a simple hand-drawn sketch showing the view, the section view, the element, its bounding box and the relationships between these would help understand better... "For I am a bear of very little brain, and" ... multi-view transforms ... "bother me" (Winnie the Pooh).

 

Thank you!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 4

Anonymous
Not applicable

Jeremy,

Please see my attached sketch. I had to add some digital notes, because my scanner kept cutting part of the drawing off. Hopefully, you can make out and understand what I am trying to explain. I would also like to point out that the element, and section line can be rotated a full 90-degrees (a section line running from Plan North to South) and I will still get the expected BoundingBox Min/Max values from the element in relation to the section's view direction. Additionally, the dotted lines in the "Section View" areas is a representation of the depth. I did not sketch out the BoundingBox representation, instead I provided the min/max values, and subtracted the difference to provide the dimensions of the BoundingBox in X, Y, & Z. 

Message 4 of 4

Anonymous
Not applicable

Hi Pat, how did you finally solved your question?...I've been dealing with a piece of code trying to get bounding boxes from windows/doors, getting their coordinates and from there replacing them with openings...nice till I realize same as you, that while they are parallel to cardinal axis the result looks beautiful but if they have any rotation in 3D space respect to cardinal axis then the code returns, in my case,  a "deformed opening". Im a newbie in revit coding but I've reading a lot and sincerely now have big mess with this, dont have very clear if we have ONLY BoundingBoxXYZ Class that its ALWAYS parallel to cardinal axis OR if there is TOO another method that returns an "fixed to object bounding box" no matters its 3D model position.

 

Thanks,