[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46632] trunk/blender/release/scripts/ startup/bl_operators/object.py: select camera operator now works with view3d unlocked cameras,

Campbell Barton ideasman42 at gmail.com
Mon May 14 16:39:21 CEST 2012


Revision: 46632
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46632
Author:   campbellbarton
Date:     2012-05-14 14:39:21 +0000 (Mon, 14 May 2012)
Log Message:
-----------
select camera operator now works with view3d unlocked cameras,
also corrected description.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_operators/object.py

Modified: trunk/blender/release/scripts/startup/bl_operators/object.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/object.py	2012-05-14 14:32:05 UTC (rev 46631)
+++ trunk/blender/release/scripts/startup/bl_operators/object.py	2012-05-14 14:39:21 UTC (rev 46632)
@@ -104,24 +104,29 @@
 
 
 class SelectCamera(Operator):
-    '''Select object matching a naming pattern'''
+    '''Select the active camera'''
     bl_idname = "object.select_camera"
     bl_label = "Select Camera"
     bl_options = {'REGISTER', 'UNDO'}
 
-    @classmethod
-    def poll(cls, context):
-        return context.scene.camera is not None
-
     def execute(self, context):
         scene = context.scene
-        camera = scene.camera
-        if camera.name not in scene.objects:
+        view = context.space_data
+        if view.type == 'VIEW_3D' and not view.lock_camera_and_layers:
+            camera = view.camera
+        else:
+            camera = scene.camera
+
+        if camera is None:
+            self.report({'WARNING'}, "No camera found")
+        elif camera.name not in scene.objects:
             self.report({'WARNING'}, "Active camera is not in this scene")
+        else:
+            context.scene.objects.active = camera
+            camera.select = True
+            return {'FINISHED'}
 
-        context.scene.objects.active = camera
-        camera.select = True
-        return {'FINISHED'}
+        return {'CANCELLED'}
 
 
 class SelectHierarchy(Operator):




More information about the Bf-blender-cvs mailing list