Is there a hot key to undo a view port change similar to the bracket key in Maya?
I've looked through the hotkeys and don't see anything.
Thank you.
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.
Sign up to join this communityIs there a hot key to undo a view port change similar to the bracket key in Maya?
I've looked through the hotkeys and don't see anything.
Thank you.
I encountered many bugs so this is more of a proof of concept than ready solution
I adapted the code from here.
Run the below code, make some changes to viewport and press CTRL + SHIFT + F12 to undo viewport changes (keeping track of a few more properties has to be added e.g. orthogonal/perspective)
bl_info = {
"name": "Work Macro",
"category": "Object",
}
import bpy, time
from collections import defaultdict
timeout = 1 # number of seconds between changes justifying a separate state
undo_buffer_size = 100 # in this crude implementation, each buffer will grow
# to double its limit before being truncated to the limit
states = defaultdict(list) # key: space object, value: list of tuples(last_change, view_matrix)
view_handler = None
def callback():
# perhaps you can only use context.area.spaces.active instead of iterating here
areas = bpy.data.window_managers[0].windows[0].screen.areas
for area in (a for a in areas if a.type == 'VIEW_3D'):
for space in (s for s in area.spaces if s.type == 'VIEW_3D'):
space_states = states[space]
if not space_states: # empty list
space_states.append((time.time(), space.region_3d.view_matrix.copy()))
else:
last_time, view_matrix = states[space][-1]
matrix_change = view_matrix != space.region_3d.view_matrix
if matrix_change and time.time() - last_time > timeout:
states[space].append((time.time(), space.region_3d.view_matrix.copy()))
if len(states[space]) > undo_buffer_size * 2:
states[space] = states[space][-undo_buffer_size:]
class WorkMacro(bpy.types.Operator):
"""Work Macro"""
bl_idname = "object.work_macro"
bl_label = "Work Macro"
bl_options = set()
def execute(self, context):
space = context.area.spaces.active
if len(states[space]) > 1:
states[space].pop() # remove current state
revert_to = states[space][-1][1].copy()
space.region_3d.view_matrix = revert_to
#sometimes the above will slightly modify the matrix so let's update the undo state with it:
states[space][-1] = (time.time(), space.region_3d.view_matrix.copy())
return {'FINISHED'}
# store keymaps here to access after registration
addon_keymaps = []
def register():
bpy.utils.register_class(WorkMacro)
# handle the keymap
wm = bpy.context.window_manager
km = wm.keyconfigs.addon.keymaps.new(name='3D View Generic', space_type='VIEW_3D')
kmi = km.keymap_items.new(WorkMacro.bl_idname, 'F12', 'PRESS', ctrl=True, shift=True)
addon_keymaps.append(km)
global view_handler
view_handler = bpy.types.SpaceView3D.draw_handler_add(callback, (), 'WINDOW', 'POST_VIEW')
def unregister():
print('unregister')
bpy.utils.unregister_class(WorkMacro)
# handle the keymap
wm = bpy.context.window_manager
for km in addon_keymaps:
wm.keyconfigs.addon.keymaps.remove(km)
# clear the list
del addon_keymaps[:]
bpy.types.SpaceView3D.draw_handler_remove(view_handler, 'WINDOW') # remove handler added on end of register() function
if __name__ == "__main__":
register()
There is no feature/hot key in Blender that allows the viewport moves to be undone. However, you can undo other actions with Ctrl+Z. Blender, sadly does not support undoing of viewport motions and editor locations, and the location of the 3D cursor. However, there are some addons that may be able to help you with those.
Just wanted to suggest that you could open a new workspace specifically for view angles you want to keep.