16
$\begingroup$

I was wondering if it was possible to lock the view (similar to quad view), so that the view doesn't change if I accidentally bump the middle mouse button.

Is there a setting I can change or a script that can do this?

$\endgroup$
10
$\begingroup$

Short answer - no.

However this may help...

  • I assume that you may have a view rotation that took some time to setup, if this is the case you could...

    • Add an empty, Enable Align to View
    • Then use 'Shift+Numpad1/3/7' to change the views aligned to the active object.
  • Quad view allows you to lock/unlock the view rotation. This is intended so you can maintain top/front/side views with one user view, but theres nothing stopping you setting up the rotation you want, then locking the view.

If you really want to do this with a script by writing an operator that intercepts view rotate and makes the choice to run or not, but I wouldn't recommend doing this since its fairly involved for such a small change.

$\endgroup$
1
  • 2
    $\begingroup$ Note, when checking align to view, I noticed the viewport would flip direction, committed fix (will be in 2.68) projects.blender.org/scm/… $\endgroup$
    – ideasman42
    May 26 '13 at 18:26
11
$\begingroup$

One way you might want to go about this would be to:

  1. Align Active Camera to View with CtrlAlt + Numpad 0.
  2. Lock Camera to View.
  3. Select the camera and lock it's transformations.
$\endgroup$
1
  • 1
    $\begingroup$ "lock it's transformations." is a dead link. This is why Stack Exchange sites don't allow links as answers, always include the info in the answer $\endgroup$
    – endolith
    Sep 13 '20 at 15:55
10
$\begingroup$

You can't lock the rotation of the view but you can lock the pan of the view to always center on the 3D Cursor.

Lock view to cursor

$\endgroup$
1
  • $\begingroup$ Omg you have helped me understand an issue I've had in one scene for ages. That lock to object box had a selection and I'd no idea how this happened. THANK YOU $\endgroup$
    – Neil
    Oct 3 '17 at 7:36
3
$\begingroup$

Update: Ok following comment from @Duarte Farrajota Ramos, I have created an AddOn for you:

  1. Save the following text in a text file(Example): lockViewRotation.py

    bl_info = {
        "name": "Lock View Rotation",
        "blender": (2, 80, 0),
        "category": "View",
    }
    
    import bpy
    
    def draw_lock_rotation(self, context):
        layout = self.layout
        view = context.space_data
        col = layout.column(align=True)
        col.prop(view.region_3d, "lock_rotation", text="Lock View Rotation")
    
    def register():
        bpy.types.VIEW3D_PT_view3d_lock.append(draw_lock_rotation)
    
    
    def unregister():
        bpy.types.VIEW3D_PT_view3d_lock.remove(draw_lock_rotation)
    
    if __name__ == "__main__":
        register()
    
  2. In blender go to Edit->Preferences -> Add-ons and Click the "Install..." button and chose the previously saved file

  3. Go to the "Community" tab and search for "Lock View Rotation" Addon and enable it (If you dont find it then close the properties panel and open it again)

  4. Now you will have an option "Lock View Rotation" in your View Lock section so you can create 4 views dragging the corners to split the current view in 4 (top, bottom, right, and perspective) and set the new Lock Rotation on the first 3.

enter image description here

Original Answer:

I have accomplish that in this way:

  • First Go to to you blender installation path (generally C:\Program Files\Blender Foundation\Blender 2.90\ in my case). And search for the file called: space_view3d.py in Blender 2.##\2.##\scripts\startup\bl_ui\space_view3d.py

  • Copy this file to a different location (as you wont be able to edit it directly)

  • Edit this file and search for the line containing: class VIEW3D_PT_view3d_lock(Panel):

this line is the definition for the "lock" options.

  • Go at the end of the: def draw(self, context): (this is the definition of the draw function for the "lock" options )

  • Add the following line indented at the end of the function (be careful with indentation):

col.prop(view.region_3d, "lock_rotation", text="Lock Rotation")
  • In my case the final code looks like that:
class VIEW3D_PT_view3d_lock(Panel):
        bl_space_type = 'VIEW_3D'
        bl_region_type = 'UI'
        bl_category = "View"
        bl_label = "View Lock"
        bl_parent_id = "VIEW3D_PT_view3d_properties"

        def draw(self, context):
            layout = self.layout

            layout.use_property_split = True
            layout.use_property_decorate = False  # No animation.

            view = context.space_data

            col = layout.column(align=True)
            sub = col.column()
            sub.active = bool(view.region_3d.view_perspective != 'CAMERA' or view.region_quadviews)

            sub.prop(view, "lock_object")
            lock_object = view.lock_object
            if lock_object:
                if lock_object.type == 'ARMATURE':
                    sub.prop_search(
                        view, "lock_bone", lock_object.data,
                        "edit_bones" if lock_object.mode == 'EDIT'
                        else "bones",
                        text="",
                    )
            else:
                subcol = sub.column(heading="Lock")
                subcol.prop(view, "lock_cursor", text="To 3D Cursor")

            col.prop(view, "lock_camera", text="Camera to View")
            # Show the Lock Rotation option on View Properties 
            col.prop(view.region_3d, "lock_rotation", text="Lock Rotation")

I just have added the last 2 lines, the first line is just a comment, and the second one is the one that's adds the "Lock Rotation" check box to your view locking properties (as specified before)

  • Replace the original file.

  • Relaunch Blender

  • Now create a new Workspace, based on General Layout using the little "+" symbol at the top right for the different workspaces, name it as you want. enter image description here

  • Then create 4 views dragging the corners to split the current view in 4 (top, bottom, right, and perspective) and set the new Lock Rotation on the first 3.

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ Suggest instead of editing blenders UI (IMO a slippery slope) define a draw method with the change def draw_lock(self, context): and append it to the panel bpy.types.VIEW3D_PT_view3d_lock.append(draw_lock) $\endgroup$
    – batFINGER
    Dec 3 '20 at 16:45
1
$\begingroup$

Here is an Viewport lock addon, may be the addon is a real decision for Your issue? https://blenderartists.org/t/wlock-an-addon-for-blender-2-8-which-allows-to-lock-3d-view-rotation-using-hotkey-default-alt-w/1163353

This addon allows to lock 3D view rotation (only 3D view) using hotkey. As an additional indicator a 'lock' icon is displayed (can be set up or disabled in Preferences).

$\endgroup$
2
  • 1
    $\begingroup$ Hello and welcome. We are looking for answers that give some context and explanation of how and why they work. Could you edit your answer and add a short description of what the addon does and why it works? $\endgroup$ Jun 9 '19 at 1:00
  • $\begingroup$ This add-on is awesome. Blender should really have such a toggle in the View menu $\endgroup$ Nov 26 '19 at 9:49
1
$\begingroup$

Check out this add on by Jason van Gumster(fweeb)

Described like this:

It locks the 3D View to whatever viewing angle you’re currently using, kind of like the ortho views when you use Quad View… but this works for any arbitrary viewing angle.

[...] I discovered that the feature is actually in the Blender Python API, there’s just no way to access it in the UI.So I fixed that.

$\endgroup$
2
  • 1
    $\begingroup$ Link dead 404 not found $\endgroup$ Oct 29 '18 at 19:06
  • $\begingroup$ What was the add-on's name? $\endgroup$ Nov 26 '19 at 9:37

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.