Manipulating the camera view
If I understand this correctly you can manipulate which portion of you design shows in the window by manipulating the Camera object. I was able to figure out how to get it to do an API "fit view" operation, which is somewhat, but not quite, what a Find In Window browser operation does.
Fit View causes the entire design (well, at least the parts of the design that are currently visible, via their Light Bulb icons) to be maximized in the window, In my case the design is taller than it is wide, so the top of the design just touches the top of the display window and the bottom of the design just touches the bottom o f the display window.
Prior to doing the Fit View my window looks like this:
AFTER the Fit View operation it looks like this:
BUT, if instead of doing the Fit View (via my C++ script) I just click on the entire project in the browser and select to Find In Window, I get this.
Which does NOT maximize the image but rather leaves some room at the top and bottom. It's kind of like the "camera" has been moved back from the object.
I want to be able to do something like that but via my C++ script. I tried writing some code that uses the Camera eye object. I made sure that the Z axis of the object is pointing directly perpendicular to the screen and modified the z component of the eye object, as in this code:
bool CenterAndShowInWindowAllVisibleObjects() { Ptr<Viewport> viewPort = theFusion360Application->activeViewport(); if (!viewPort) return false; Ptr<Camera> TheCamera = viewPort->camera(); if (!TheCamera) return false; TheCamera->isFitView(true); viewPort->camera(TheCamera); return TRUE; } bool ZoomOutToShowInWindowAllVisibleObjects() { // This is different than CenterAndShowInWindowAllVisibleObjects in that // we want to move the camera back a bit so that everything shown doesn't // simply extend to the outer edges of the windo. In particular we // want to assure that any movement or, for example, landing gear deployments // are fully visible. Ptr<Viewport> viewPort = theFusion360Application->activeViewport(); if (!viewPort) return false; Ptr<Camera> TheCamera = viewPort->camera(); if (!TheCamera) return false; // Get the existing CameraPosition Ptr<Point3D> CameraPosition = TheCamera->eye(); Show("EXISTING Camera Position X,Y,Z = " + std::to_string(CameraPosition->x()) + "," + std::to_string(CameraPosition->y()) + "," + std::to_string(CameraPosition->z())); // Modify the CameraPosition, effectively pulling it back a bit, perpendicular to the center of the window. // It's the Z axis (for the overall project) that is perpendicular to the surface of the screen, i.e. towards (+) you and away from you (-). double CameraPositionZ = CameraPosition->z(); double AmountToPullBackInCentimeters = 200; CameraPosition->z(CameraPositionZ + AmountToPullBackInCentimeters); // Set the value of the property, where value_var is a Point3D. TheCamera->eye(CameraPosition); viewPort->camera(TheCamera); UpdateImage(); Show("NEW Camera Position X,Y,Z = " + std::to_string(CameraPosition->x()) + "," + std::to_string(CameraPosition->y()) + "," + std::to_string(CameraPosition->z())); return TRUE; }
The first method basically does the FitView operation. And that does indeed get the object fitted into view.
The second method is intended to basically "pull back" from the view, which SHOULD (I think) result in the object looking a bit smaller in the window and be more like what you get when you use the Find In Window operation from the Browser. But it doesn't. Instead it seems to re-orient the displayed object.
I've tried lots of different approaches but can't seem to get it to do what I want. Basically, no matter how the object is oriented within the window, I want to be able to zoom-out much like the Browser's Find In Window operation works.
Ideally, I'd also like to be able to do, through my C++ script, the operations you get when you click on the various faces of the little cube in the upper right corner.
Is that possible?
Is there any documentation/examples on how to effectively use the Camera object?