0
$\begingroup$

I'm learning how the 3d viewport and the camera objects rotate around the pivot point (I'm not sure this is the correct lingo, but for the sake of the question I will use it).

I have been searching a lot about this specific subject but i can only find answer about how to change the pivot point to the 3D cursor using keyboard shortcuts.

Since it doesn't seem to be possible to show these pivot points in the viewport itself, what I'm trying to understand now is if it is possible to get them using python. I don't think there is any relevant member in the camera object:

>>> dir(cam)
['__doc__', '__module__', '__slots__', 'active_material', 'active_material_index', 'active_shape_key', 'active_shape_key_index', 'animation_data', 'animation_data_clear', 'animation_data_create', 'animation_visualization', 'bl_rna', 'bound_box', 'cache_release', 'calc_matrix_camera', 'camera_fit_coords', 'children', 'closest_point_on_mesh', 'collision', 'color', 'constraints', 'convert_space', 'copy', 'cycles', 'cycles_visibility', 'data', 'delta_location', 'delta_rotation_euler', 'delta_rotation_quaternion', 'delta_scale', 'dimensions', 'display', 'display_bounds_type', 'display_type', 'empty_display_size', 'empty_display_type', 'empty_image_depth', 'empty_image_offset', 'empty_image_side', 'evaluated_get', 'face_maps', 'field', 'find_armature', 'generate_gpencil_strokes', 'grease_pencil_modifiers', 'hide_get', 'hide_render', 'hide_select', 'hide_set', 'hide_viewport', 'holdout_get', 'image_user', 'indirect_only_get', 'instance_collection', 'instance_faces_scale', 'instance_type', 'is_deform_modified', 'is_embedded_data', 'is_evaluated', 'is_from_instancer', 'is_from_set', 'is_instancer', 'is_library_indirect', 'is_modified', 'library', 'local_view_get', 'local_view_set', 'location', 'lock_location', 'lock_rotation', 'lock_rotation_w', 'lock_rotations_4d', 'lock_scale', 'make_local', 'material_slots', 'matrix_basis', 'matrix_local', 'matrix_parent_inverse', 'matrix_world', 'mode', 'modifiers', 'motion_path', 'name', 'name_full', 'original', 'override_create', 'override_library', 'parent', 'parent_bone', 'parent_type', 'parent_vertices', 'particle_systems', 'pass_index', 'pose', 'pose_library', 'preview', 'proxy', 'proxy_collection', 'ray_cast', 'rigid_body', 'rigid_body_constraint', 'rna_type', 'rotation_axis_angle', 'rotation_euler', 'rotation_mode', 'rotation_quaternion', 'scale', 'select_get', 'select_set', 'shader_effects', 'shape_key_add', 'shape_key_clear', 'shape_key_remove', 'show_all_edges', 'show_axis', 'show_bounds', 'show_empty_image_only_axis_aligned', 'show_empty_image_orthographic', 'show_empty_image_perspective', 'show_in_front', 'show_instancer_for_render', 'show_instancer_for_viewport', 'show_name', 'show_only_shape_key', 'show_texture_space', 'show_transparent', 'show_wire', 'soft_body', 'tag', 'to_mesh', 'to_mesh_clear', 'track_axis', 'type', 'up_axis', 'update_from_editmode', 'update_tag', 'use_dynamic_topology_sculpting', 'use_empty_image_alpha', 'use_fake_user', 'use_grease_pencil_lights', 'use_instance_faces_scale', 'use_instance_vertices_rotation', 'use_shape_key_edit_mode', 'user_clear', 'user_of_id', 'user_remap', 'users', 'users_collection', 'users_scene', 'vertex_groups', 'visible_get', 'visible_in_viewport_get']

If this location is not available is there any suggested way to derive it?

EDIT:

to make clear wath I intend for pivot point: when you press Center View to Cursor:

enter image description here

The pivot point of the view will become the Cursor itself. As soon as you Move the current view the pivot will move, is there a way to get the coordinates of this point?

$\endgroup$
2
  • 2
    $\begingroup$ What do you mean by "pivot point"? Camera axis? $\endgroup$ – lemon Oct 29 '20 at 17:48
  • $\begingroup$ @lemon I added more information $\endgroup$ – Luca Oct 29 '20 at 19:35
2
$\begingroup$

You're looking in the wrong place basically. What you need to do is get the RegionView3D of whatever 3d window you want to get the pivot point (view_location) of.

API docs

Something like this should work:

import bpy

def get_rv3d():
    for area in bpy.context.screen.areas:
        if area.type == 'VIEW_3D':
            rv3d = area.spaces[0].region_3d
            if rv3d is not None:
                return rv3d
    return None
            
rv3d = get_rv3d()
if rv3d:
    print(rv3d.view_location)
$\endgroup$
1
  • $\begingroup$ wow, it works, thank you very much! i just realize that the camera obj itself doesn't have this property because it is only something happening in the vieport itself, i got confused because i was locking the camera to the view. $\endgroup$ – Luca Oct 30 '20 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.