Skip to content

Instantly share code, notes, and snippets.

@Fweeb

Fweeb/lockview.py

Last active Nov 29, 2020
Embed
What would you like to do?
Blender add-on for exposing the 3D View's rotation locking feature
# ***** BEGIN GPL LICENSE BLOCK *****
#
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ***** END GPL LICENCE BLOCK *****
bl_info = {
"name": "Lock View",
"description": "Exposes rotation locking in the 3D View to a specific viewing angle",
"author": "Jason van Gumster (Fweeb)",
"version": (1, 0, 0),
"blender": (2, 76, 0),
"location": "3D View > Properties Region > View",
"warning": "",
"wiki_url": "",
"tracker_url": "",
"category": "3D View"}
import bpy
def lock_ui(self, context):
layout = self.layout
layout.prop(context.space_data.region_3d, 'lock_rotation', text='Lock View Rotation')
def register():
bpy.types.VIEW3D_PT_view3d_properties.append(lock_ui)
def unregister():
bpy.types.VIEW3D_PT_view3d_properties.remove(lock_ui)
if __name__ == "__main__":
register()
@Tibuq

This comment has been minimized.

Copy link

@Tibuq Tibuq commented Jul 25, 2016

Features I'd love to see:

  1. Don't prevent the ability to switch between views like top/right/front (numpad 1,3,7 by default), flip the view (numpad 9 by default) or switch between ortho and persp (numpad 5 by default) while view rotation is locked.
    -> ONLY prevent view rotation through mouse input. ('view3d.rotate')
  2. Add option to reuse 'Rotate View' ('view3d.rotate') hotkey for a different action while view rotation is locked.
    e.g. 'Rotate View' is bound to 'Right Mouse'. 'Right Mouse' does nothing while view rotation is locked. -> Let me bind 'Right Mouse' to 'Move View' while view rotation is locked but remain its original use while view rotation is not locked.
@DanTheColoradan

This comment has been minimized.

Copy link

@DanTheColoradan DanTheColoradan commented Jan 31, 2018

I just wanted to say good work.

@swordfighter79

This comment has been minimized.

Copy link

@swordfighter79 swordfighter79 commented May 22, 2018

thanks that is exactly what I needed thanks alot it a great help

@iamtitere

This comment has been minimized.

Copy link

@iamtitere iamtitere commented Jan 2, 2020

Thanks you so much!

Important if people wants to import it to Blender 2.8x, the code line

"blender": (2, 76, 0),

must be updated after importing to the blender version, so

"blender": (2, 80, 0),

and the menu is on the 3D View>right panel>View>Lock View Rotation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.