how to get Bounding Box of room element when it is in 3d?

how to get Bounding Box of room element when it is in 3d?

prasannamurumkar
Advocate Advocate
3,967 Views
13 Replies
Message 1 of 14

how to get Bounding Box of room element when it is in 3d?

prasannamurumkar
Advocate
Advocate

want to get min,max of room so used below code.

boundingBox = room.get_BoundingBox(revitDocument.ActiveView);

got bounding box.

When model is in 3D used below code

View3D view3d = revitDocument.ActiveView as View3D;

BoundingBoxXYZ boundingBox = room.get_BoundingBox(view3d);

 

Here boundingBox  is getting null.Is their other way to get min,max of  room element?

or Is their other way to get bounding box of room element when it is in 3D?

 

0 Likes
3,968 Views
13 Replies
Replies (13)
Message 2 of 14

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @prasannamurumkar ,

I don't see any problem with your code.

The code works fine.

Before retrieving the bounding box,  make sure the room and view3D are not null.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 3 of 14

prasannamurumkar
Advocate
Advocate

Thank you for reply.

apologize for late reply.

The issue may be room is not  viewable in 3d.

because when i try to select element by room Id by manually it not get selected in 3d.

 

when i try to select element by room Id by manually it  get selected in 2d.

0 Likes
Message 4 of 14

RPTHOMAS108
Mentor
Mentor

The Room class has a ClosedShell property which gives a GeometryElement object containing a solid so I assume you can get the BoundingBox from that. 

Message 5 of 14

jeremytammik
Autodesk
Autodesk

Thank you Richard for the good suggestion!

 

@prasannamurumkar , please confirm that the bounding box of the room ClosedShell property returns the information you require.

 

Thank you!

 



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

0 Likes
Message 6 of 14

prasannamurumkar
Advocate
Advocate

yes will try and update here if got bounding box property of room when it is in 3d.

0 Likes
Message 7 of 14

prasannamurumkar
Advocate
Advocate

Thank you for reply.

Getting bounding box property by below.

 

GeometryElement geoElement = room.ClosedShell;
BoundingBoxXYZ boundingBox = geoElement.GetBoundingBox();

XYZ min = boundingBox.Min;
XYZ max = boundingBox.Max;

here min ,max are 

min = {(1000000000000000019884624838656.000000000, 1000000000000000019884624838656.000000000, 1000000000000000019884624838656.000000000)}
max={(-1000000000000000019884624838656.000000000, -1000000000000000019884624838656.000000000, -1000000000000000019884624838656.000000000)}

 

For 2D if used below

BoundingBoxXYZ boundingBox = room.get_BoundingBox(revitDocument.ActiveView);

In 2D min,max are

(52.255591027, 17.974775141, 50.196850394)}
{(60.255591027, 23.974775141, 57.102362205)

 

min,max are important in my case because calculating room size by this.

 

 

 

 

 

as whole purpose of getting bounding box to get room size.

as i am going to highlight those room with any dimension having less than 10 feet.

so it is coming less than 10 feet in 2D for same room it is not coming less than 10 feet for 3D.

 

 

 

 

 

 

0 Likes
Message 8 of 14

RPTHOMAS108
Mentor
Mentor

I don't understand those limits you are getting in 3D unless your room is containing both the earth and the moon.

 

I get the following for a simple room with null view. Basically around  12'x14', noting that bounding box transform is not parallel with the room (this would always have been the case). Interrorgating the solid of the shell itself may give you a better understanding of actual room dimensions.

 

Capture200908.PNG

 

 

 

0 Likes
Message 9 of 14

prasannamurumkar
Advocate
Advocate

1.PNG

 

In 3d Bounding box null.

2.PNG

In 2d Bounding box getting.

3.PNG

0 Likes
Message 10 of 14

RPTHOMAS108
Mentor
Mentor

What is the purpose of your second image?

 

If the room is not bounded the Shell will contain a bounding box of this size:

 (1E+30, 1E+30, 1E+30), (-1E+30, -1E+30, -1E+30)

 

However you also would have noted this warning 'Room is not in a properly enclosed region'. That is the only way I currently understand you could get those large numbers. Perhaps attach a project file of the room and it's boundaries.

 

0 Likes
Message 11 of 14

prasannamurumkar
Advocate
Advocate

Thank you for reply.

purpose of second and third image is when model is open in 2d got result expected unlike image 1.

for below model

could you comment for room having id 1669441.

why in 3d not getting right result?

 also tried to search element id by click on manage select by id and then search for 1669441.

when it is in 3d element not searched.but when model is in2d it get seached.

 

0 Likes
Message 12 of 14

RPTHOMAS108
Mentor
Mentor

As noted the room in question is unbounded:

 

Capture200908aa.PNG

 

The walls of the room appear to be made up of two parallel walls of 2mm thick noted as 'AR-EXTERNAL PAINT':

 

Capture200908bb.PNG

 

I don't know what the doors are hosted in (not the 2mm paint walls). Therefore there is no closed loop of walls to enclose the room. You could perhaps use 'Room Separator' lines to close the door positions. However as currently modelled your would need an entirely different approach with the API to calculate room size. 

 

i.e. rooms with correct boundaries indicate a cross over the entire area, not as below:

 

Capture200908cc.PNG

 

Groups may also be affecting the siuation it may be that the rooms need to go in the same group as the walls you want bounding them (I'm not entirely sure about that but this is the case for links).

 

 

Message 13 of 14

prasannamurumkar
Advocate
Advocate

thanks for your time.

0 Likes
Message 14 of 14

RPTHOMAS108
Mentor
Mentor

You have floor elements used as floor finishes and ceilings inside each room it seems. So you could use these to give you approx. room dimensions. Extract the solid geometry from floor and ceiling in each room, union floor and ceiling of each room and get the bounding box of that. This will be oversized for some of your L-Shaped rooms etc.

 

You'll use

BooleanOperationUtils.ExecuteBooleanOperation(FloorSolid, CeilingSolid, Union)

 

I believe this will create a single solid with seperate volumes (hence the method SolidUtils.SplitVolumes). It may be just as easy to compare the face origins of floor and ceiling to get the room height.

 

None of the above requires transactions since you are not adding to the document.

0 Likes