Zoom out in a view3D or expanding

Zoom out in a view3D or expanding

Anonymous
Not applicable
750 Views
1 Reply
Message 1 of 2

Zoom out in a view3D or expanding

Anonymous
Not applicable

Hi everyone!

 

This post is regarding about a previous post https://forums.autodesk.com/t5/revit-api-forum/create-a-view-camera-or-3d-view-with-boundering/td-p/...

 

This post was solved but I have a new doubt about this issue, I changed a bit my code respect the solution. Concretely in the orientation. Placing the eye in the top of the wall, and with an angle not perpendicular to the Z-axis. But I need to have zoom out or change the size of the box, and this is my problem, I don't know how I could do it!

 

I tried it, changing the boundingBox but it didn't change...

 

My code is the next:

 

 

private static ViewOrientation3D GetOrientation(Room room, Wall wall3DView, UIDocument uiDoc)
        {

            var calculator = new SpatialElementGeometryCalculator(room.Document, new SpatialElementBoundaryOptions
            {
                SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish
            });
            IList<Reference> sideFaces =
                HostObjectUtils.GetSideFaces(wall3DView,
                    ShellLayerType.Interior);
            Face face =
                uiDoc.Document.GetElement(sideFaces[0])
                    .GetGeometryObjectFromReference(sideFaces[0]) as Face;
            

            var faceBox = face.GetBoundingBox();

            var faceCenter = face.Evaluate(0.5 * (faceBox.Min + faceBox.Max));
           
            var dist = 0.5;
            var h = 0.15;
            
            XYZ heightFace = new XYZ(0, 0, h);
           
            var eye = faceCenter + heightFace;
            var angulo = -1 * face.ComputeNormal(UV.Zero) - heightFace / dist;
            var up = XYZ.BasisZ - 1 * face.ComputeNormal(UV.Zero) * h / dist;
         
            return new ViewOrientation3D(eye, up, angulo);
            
        }

 

 

 

In the next code, bounding is the bounding of the room...

 

public static View3D Create3DView(Room room, Wall wall3DView, UIDocument uiDoc,BoundingBoxXYZ bounding)
        {
            var document = room.Document;

            using (var transaction = new Transaction(document, "create 3d view"))
            {
                transaction.Start();

                var view = View3D.CreatePerspective(document, document.GetDefaultElementTypeId(ElementTypeGroup.ViewType3D));
//------------------------------------------
//this is the part which is not working in a good way. BoundingBoxXYZ bb = view.CropBox; bb.Max = bounding.Max; bb.Min = bounding.Min; view.CropBox = bb;
//--------------------------------------------- view.SetOrientation(GetOrientation(room, wall3DView, uiDoc)); transaction.Commit(); return view; } }

 

 

Do you know where is the mistake? Or do you know how could I make zoom out?

If I don't use the bounding the solution will be:

 

 

 

 

Capturakitchen.PNG



 And I want a solution like the next picture: 

 

Capturakitchen2.PNG

 

Thank you and best regards

 

Lorena

 

0 Likes
751 Views
1 Reply
Reply (1)
Message 2 of 2

jeremytammik
Autodesk
Autodesk

Mostly, the most efficient way to approach problems like this is to set up the desired situation manually through the user interface, then analyse the relevant elements and their properties using RevitLookup:

 

https://github.com/jeremytammik/RevitLookup

 

In this case, I assume that those elements would be the view, its crop box, the camera, etc.

 

Here are more suggestions on how to research to solve a Revit API programming task:

 

http://thebuildingcoder.typepad.com/blog/2017/01/virtues-of-reproduction-research-mep-settings-ontol...

 

Good luck!

 

Best regards,

 

Jeremy

 



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

0 Likes