-
-
Save Fweeb/bb61c15139bff338cb17 to your computer and use it in GitHub Desktop.
# ***** 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() |
@ithil I've incorporated your update to this. Because the code is so short, I never thought to make a full-on repo for it. :) Thanks for pointing this out.
Excellent to make the viewport a reference viewer in Blender !
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!
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.
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
Yes, you simply need to update the line with the blender version as @iamtitere showed above to the version you're using.
For version 3.0.0 I've already done that so you could also just grab my fork: https://gist.github.com/ithil/ffc48aba19771d6850d1c2fc6a84d6c0