[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54147] trunk/blender/release/scripts/ startup/bl_operators/rigidbody.py: fix for rigid body assuming active object would be selected, also don' t check length of selected objects in poll function ( getting and throwing away object selection array on every redraw is no good ).

Campbell Barton ideasman42 at gmail.com
Mon Jan 28 13:24:32 CET 2013


Revision: 54147
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54147
Author:   campbellbarton
Date:     2013-01-28 12:24:25 +0000 (Mon, 28 Jan 2013)
Log Message:
-----------
fix for rigid body assuming active object would be selected, also don't check length of selected objects in poll function (getting and throwing away object selection array on every redraw is no good).

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

Modified: trunk/blender/release/scripts/startup/bl_operators/rigidbody.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/rigidbody.py	2013-01-28 12:18:00 UTC (rev 54146)
+++ trunk/blender/release/scripts/startup/bl_operators/rigidbody.py	2013-01-28 12:24:25 UTC (rev 54147)
@@ -214,13 +214,14 @@
     @classmethod
     def poll(cls, context):
         obj = context.object
-        objects = context.selected_objects
-        return (obj and obj.rigid_body and (len(objects) > 1))
+        return (obj and obj.rigid_body)
 
     def execute(self, context):
 
+        scene = context.scene
         objects = context.selected_objects
         obj_act = context.active_object
+        change = False
 
         for obj in objects:
             if obj == obj_act:
@@ -237,10 +238,15 @@
             con.type = self.con_type
             con.object1 = obj_act
             con.object2 = obj
-        # restore selection
-        bpy.ops.object.select_all(action='DESELECT')
-        for obj in objs:
-            obj.select = True;
-        bpy.context.scene.objects.active = obj_act
-
-        return {'FINISHED'}
+            change = True
+        
+        if change:
+            # restore selection
+            bpy.ops.object.select_all(action='DESELECT')
+            for obj in objects:
+                obj.select = True;
+            scene.objects.active = obj_act
+            return {'FINISHED'}
+        else:
+            self.report({'WARNING'}, "No other objects selected")
+            return {'CANCELLED'}




More information about the Bf-blender-cvs mailing list