[Bf-extensions-cvs] [79363738] master: Cleanup: camera_turnaround, remove unnecessary context access

Campbell Barton noreply at git.blender.org
Mon Jun 22 07:11:35 CEST 2020


Commit: 793637384cf175404f64f58c67e0ab0997709571
Author: Campbell Barton
Date:   Mon Jun 22 15:08:44 2020 +1000
Branches: master
https://developer.blender.org/rBA793637384cf175404f64f58c67e0ab0997709571

Cleanup: camera_turnaround, remove unnecessary context access

===================================================================

M	camera_turnaround.py

===================================================================

diff --git a/camera_turnaround.py b/camera_turnaround.py
index 935f486e..e80dc638 100644
--- a/camera_turnaround.py
+++ b/camera_turnaround.py
@@ -59,8 +59,8 @@ class CAMERATURN_OT_RunAction(Operator):
         scene = context.scene
         turn_camera = scene.turn_camera
         selectobject = context.active_object
-        camera = context.scene.camera
-        savedcursor = bpy.context.scene.cursor.location.copy()  # cursor position
+        camera = scene.camera
+        savedcursor = scene.cursor.location.copy()  # cursor position
         savedframe = scene.frame_current
         if turn_camera.use_cursor is False:
             bpy.ops.view3d.snap_cursor_to_selected()
@@ -98,7 +98,7 @@ class CAMERATURN_OT_RunAction(Operator):
         # create first frame
         myempty.rotation_euler = (0, 0, 0)
         myempty.empty_display_size = 0.1
-        context.scene.frame_set(scene.frame_start)
+        scene.frame_set(scene.frame_start)
         myempty.keyframe_insert(data_path="rotation_euler", frame=scene.frame_start)
 
         # Clear the Camera Animations if the option is checked
@@ -167,7 +167,7 @@ class CAMERATURN_OT_RunAction(Operator):
 
         # back previous configuration
         context.preferences.edit.keyframe_new_interpolation_type = savedinterpolation
-        bpy.context.scene.cursor.location = savedcursor
+        scene.cursor.location = savedcursor
 
         # -------------------------
         # Back to old selection
@@ -175,7 +175,7 @@ class CAMERATURN_OT_RunAction(Operator):
         bpy.ops.object.select_all(False)
         selectobject.select_set(True)
         bpy.context.view_layer.objects.active = selectobject
-        bpy.context.scene.frame_set(savedframe)
+        scene.frame_set(savedframe)
 
         return {'FINISHED'}
 
@@ -277,7 +277,7 @@ class CAMERATURN_PT_ui(Panel):
         turn_camera = scene.turn_camera
 
         try:
-            bpy.context.scene.camera.name
+            scene.camera.name
         except AttributeError:
             row = layout.row(align=False)
             row.label(text="No defined camera for scene", icon="INFO")



More information about the Bf-extensions-cvs mailing list