3D View - "Orient to View"

Good afternoon!

I’m searching for a way to orient a 3D view to a floor plan with the same result as shown in the picture below (in 3D view> right click view cube> Orient to View > Floor Plans > Level 1.

image

I’ve been playing around with the BoundingBoxXYZ.

I can accomplish this by using an existing 3D view by doing the following:

View3D.GetSectionBox() = view
View3D.SetSectionBox(view)

However, I’d like to be able to use the floor plans bounding box.

“ViewPlan” Class has a BoundingBoxXYZ property; however, it doesn’t seem to be returning a bounding box. I’ve tried using in the following ways:

  • ViewPlan.BoundingBox = view
    View3D.SetSectionBox(view)

  • ViewPlan.BoundingBox.Max (get error saying AttributeError: ‘indexer#’ object has no attribute ‘Max’)
    in an attempt to deconstruct and create a new BoundingBoxXYZ object to use.

Thanks for any help in advance!

bump

Urgh I’ve been trying to do this forever, I really hope someone can figure this out. I think the base issue is that the 2D plans don’t exactly have section boxes, they’re more like “View Ranges”

1 Like

Yes. It’s strange, with Revit Lookup I see the Plan View does have a BoundingBoxXYZ property but it doesn’t return one when called.

What steps have you tried so far? Have you attempted to deconstruct the view range and crop range and construct a new section box for the 3D view?

I’m going to attempt this when I get some time. Hopefully I can come up with something, I’ll let you know.

Interesting idea, unfortunately I’m not at a PC but hopefully these thoughts are of use :slight_smile:

Orientation is set like this… http://www.revitapidocs.com/2019/882f774b-b290-14b8-2664-8f86ec42f458.htm so the task is to extract them from the floor view?

Plan view crop region is from here? http://www.revitapidocs.com/2019/d6246051-ecfb-7388-0429-6ed65de72638.htm perhaps you can get the center (eye position) & direction to define up and forward?

Apologies for the gross speculation, I may be way off!

Mark

the bounding box property is an overloaded property, so you’ll need to use the get_ prefix to get it.
ex. If i need to get the room bounding box It’ll be:

room.get_BoundingBox(view)

That is where “room” is a room element (or any object really , i’m not sure though), and “view” is the view which we’ll take the bouding box from.

Here is the boundingbox method description:
“Retrieves a box that circumscribes all geometry of the element.”
"Pass in a view to query view-specific (e.g., cut) geometry or null for model
geometry. 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 null. The box will always be aligned to the default axes of the
model coordinate system (thus no rotation should be applied to the return value).
Also note that this bounding box volume
may enclose geometry that is not obvious. For example, the “flip controls” that
could be part of a family will be included in the computation of the bounding box even
though they are not always visible in the family instance of the family.
"

1 Like