Level Bounding box return null

Level Bounding box return null

ahmadeltobshy
Contributor Contributor
658 Views
4 Replies
Message 1 of 5

Level Bounding box return null

ahmadeltobshy
Contributor
Contributor

Hey everybody i have a small issue i have face hoping someone helping me

i have collected some annotation elements like Levels, ElevationMarker and so on ..

when i snoop these elements using Revit Lookup i found these elements have boundingbox and there are min and max values 

LevelSnoop.png

 

 

but when i try to get these bounding boxes or min/max value in code there are always NullReferenceException

as the image shows below 

ahmadeltobshy_0-1650944820690.png

 

i also try to assign a view/3Dview to .get_BoundingBox method instead of having null argument but still getting null all the times.

 

anyone have any idea what this happens? 

0 Likes
Accepted solutions (1)
659 Views
4 Replies
Replies (4)
Message 2 of 5

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @ahmadeltobshy ,

 

The view should be a 3d view.

Could you please try opening the 3d view in the project and use "doc.activeview"?

 

BoundingBoxXYZ boundingBox = Level.get_BoundingBox(doc.ActiveView) as BoundingBoxXYZ;
if (boundingBox!=null)
{
XYZ maxPoint = boundingBox.Max;
XYZ minPoint = boundingBox.Min;
}

Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 3 of 5

caroline.gitonga
Autodesk
Autodesk
Accepted solution

Hi,
You could try to pass the document active view

BoundingBoxXYZ bounding = elem.get_BoundingBox(doc.ActiveView);
XYZ max = bounding.Max;
XYZ xYZ = bounding.Min;
From the Revit Doc , it says

If the view box is not known or cannot be calculated, this will return the model box; if the model box is not known, this will return a null reference ( Nothing in Visual Basic)

Carol Gitonga, Developer Advocacy and Support, ADN Open
Message 4 of 5

ahmadeltobshy
Contributor
Contributor
Thank You it works for me.
0 Likes
Message 5 of 5

ahmadeltobshy
Contributor
Contributor
Thank you i have read revit docs, and by passing a view this returns a value.
0 Likes