Skip to content

Instantly share code, notes, and snippets.

@Fweeb
Last active July 28, 2026 18:51
Show Gist options
  • Select an option

  • Save Fweeb/bb61c15139bff338cb17 to your computer and use it in GitHub Desktop.

Select an option

Save Fweeb/bb61c15139bff338cb17 to your computer and use it in GitHub Desktop.
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, 1),
"blender": (3, 0, 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()
@df-0

df-0 commented May 19, 2023

Copy link
Copy Markdown

Thanks for this! I'm using this for drawing with grease pencil, for which obviously you don't want to accidentally orbit the camera. However - this does also prevent you from being able to 2D roll the view (which is useful for drawing because often you want to roll the view to draw a particular curve more easily. Any way it could lock orbit but not roll? Thanks!

@Fweeb

Fweeb commented May 21, 2023

Copy link
Copy Markdown
Author

Hi there @df-0!

I think what you're looking for is technically possible, but would certainly require quite a bit more work. Right now, this add-on is just exposing functionality that's already built into Blender.

However, there is a workaround. I'm assuming that you're using Grease Pencil from the 2D Animation template. If you do that, you have a camera object and you're drawing from that camera's view. So if you want to rotate the view, you can just select the camera object and rotate that. It's a bit clunky because you have to hop out of Draw mode to do that, so maybe an add-on could be written that allows limited camera movement from within Edit mode. Maybe I'll play with that in the next week or so.

@df-0

df-0 commented May 23, 2023

Copy link
Copy Markdown

Cool - thanks. Yes, there's definitely some workarounds! I tend to use view roll a lot when drawing in blender - there's a reason it was built into old animation light tables, and it's easily accessible in stuff like photoshop (hold R) and toon boom (hold ctrl+alt) - and you currently don't need to have a camera for it to work, but of course it gets disabled by view lock. There's a request to add this as core functionality but these things can take a while! https://blender.community/c/rightclickselect/q2cbbc/?sorting=hot

@abe-cedarian

Copy link
Copy Markdown

For posterity (anyone who happens to stumble across this link) this is now exposed natively in Blender as of 4.4: https://projects.blender.org/blender/blender/pulls/122185 in the 3D viewport Sidebar > View > View Lock > Rotation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment