# Default 3D views

**URL:** <https://community.materialise.com/t/default-3d-views/679>\
**Category:** MIS - Scripting Forum\
**Tags:** mimics\
**Created:** [November 3, 2022, 5:47pm UTC](https://community.materialise.com/t/default-3d-views/679 "2022-11-03T17:47:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmeth](https://avatars.discourse-cdn.com/v4/letter/p/90db22/32.png) [@pmeth](https://community.materialise.com/u/pmeth)\
**Post date:** [November 3, 2022, 5:47pm UTC](https://community.materialise.com/t/default-3d-views/679/1 "2022-11-03T17:47:32Z")

</div>

Is there an easy way to apply the default 3D views (Anterior, Left, Top, …) from a script? i.e. the same functionality provided by the “Select 3D View” in the GUI.

Ideally I want this to apply a zoom and pan so that the visible parts are centred in the 3D view.

Is this possible or do I have to workout the required camera settings and apply those?

---

<div class="post-metadata">

**Author:** ![imaninanoh](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.materialise.com/imaninanoh/32/123_2.png) [@imaninanoh](https://community.materialise.com/u/imaninanoh)\
**Post date:** [November 11, 2022, 1:00pm UTC](https://community.materialise.com/t/default-3d-views/679/2 "2022-11-11T13:00:01Z")

</div>

Hi Peter,

Thank you for contacting us.

To answer your question regarding centered view, we have a built-in function to obtain the bounding box of a part, as well as a built-in function to set the camera to a bounding box.

Example of how we can use this function is as below:

_bbox = mimics.measure.get\_bounding\_box()_  
_view = mimics.data.views[‘3D’]_  
_camera = view.get\_camera( )_  
_camera.zoom\_to\_bounding\_box(bounding\_box = bbox)_

You will notice this sets the camera zoom to a very tight fit on the bounding box, especially if the bbox is positioned parallel to the views. You can fix this by slightly zooming out using _zoom\_factor_ (for example: 0.5):  
_camera.zoom\_factor = camera.zoom\_factor - 0.5_

Regarding anterior, post, … views, these views are all defined by their _up\_vector_ and _view\_vector._  
_up\_vector_ defines the coordinate axis’ upright position, which will limit 2 out of 3 axis to the desired position. The third axis you then fine-tune by using _view\_vector,_ as you can use it to define the orthogonal view on this upright plane.

Both are accessible via the same _camera_ object:  
_camera.up\_vector_  
_camera.view\_vector_

For example, for anterior view (by manually using the A shortcut in Mimics to go to that view), you can obtain its view\_vector and up\_vector:

_manually press shortcut A while in 3D view_  
_camera = view.get\_camera( )_  
_camera.up\_vector_  
_camera.view\_vector_

For this example, you’ll receive (0, 0, 1) and (0, 1, 0) respectively. These are the 2 vectors defining the anterior view. Thus, in your script, you can set the camera\_settings of whichever 3D view you obtained to this, and it will give you that anterior view:

_camera = view.get\_camera( )_  
_camera.up\_vector = (0, 0, 1)_  
_camera.view\_vector = (0, 1, 0)_

gives you back the anterior view, regardless of what position the camera was in before.

Please let me know if this info helps you with your concerns, and feel free to ask if you have further questions :)

Kind regards,  
Imanina
