Default 3D views

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?

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