[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [636] trunk/py/scripts/addons: collections like context. selected_objects no longer return None for empty lists.
Campbell Barton
ideasman42 at gmail.com
Sat Apr 24 21:35:58 CEST 2010
Revision: 636
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=636
Author: campbellbarton
Date: 2010-04-24 21:35:58 +0200 (Sat, 24 Apr 2010)
Log Message:
-----------
collections like context.selected_objects no longer return None for empty lists. Update scripts for this.
also removed check for obj.data == None for a mesh. This will never happen.
Modified Paths:
--------------
trunk/py/scripts/addons/add_edit_object_parameters.py
trunk/py/scripts/addons/io_anim_camera.py
trunk/py/scripts/addons/mesh_relax.py
trunk/py/scripts/addons/object_cloud_gen.py
trunk/py/scripts/addons/space_view3d_panel_measure.py
Modified: trunk/py/scripts/addons/add_edit_object_parameters.py
===================================================================
--- trunk/py/scripts/addons/add_edit_object_parameters.py 2010-04-23 11:53:35 UTC (rev 635)
+++ trunk/py/scripts/addons/add_edit_object_parameters.py 2010-04-24 19:35:58 UTC (rev 636)
@@ -174,7 +174,6 @@
# Only show this panel if the object has "recall" data.
if (ob
- and context.selected_objects
and len(context.selected_objects) == 1
and ob == context.selected_objects[0]
and 'recall' in ob):
Modified: trunk/py/scripts/addons/io_anim_camera.py
===================================================================
--- trunk/py/scripts/addons/io_anim_camera.py 2010-04-23 11:53:35 UTC (rev 635)
+++ trunk/py/scripts/addons/io_anim_camera.py 2010-04-24 19:35:58 UTC (rev 636)
@@ -103,7 +103,7 @@
for marker in scene.timeline_markers:
fw("marker = scene.timeline_markers.add('%s')\n" % marker.name)
fw("marker.frame = %d + frame\n" % marker.frame)
-
+
# will fail if the cameras not selected
if marker.camera:
fw("marker.camera = cameras.get('%s')\n" % marker.camera.name)
Modified: trunk/py/scripts/addons/mesh_relax.py
===================================================================
--- trunk/py/scripts/addons/mesh_relax.py 2010-04-23 11:53:35 UTC (rev 635)
+++ trunk/py/scripts/addons/mesh_relax.py 2010-04-24 19:35:58 UTC (rev 636)
@@ -50,14 +50,13 @@
from bpy.props import IntProperty
def relax_mesh(context):
-
+
+ # deselect everything that's not related
+ for obj in context.selected_objects:
+ obj.selected = False
+
# get active object
obj = context.active_object
-
- # deselect everything that's not related
- if context.selected_objects:
- for o in context.selected_objects:
- o.selected = False
# duplicate the object so it can be used for the shrinkwrap modifier
obj.selected = True # make sure the object is selected!
Modified: trunk/py/scripts/addons/object_cloud_gen.py
===================================================================
--- trunk/py/scripts/addons/object_cloud_gen.py 2010-04-23 11:53:35 UTC (rev 635)
+++ trunk/py/scripts/addons/object_cloud_gen.py 2010-04-24 19:35:58 UTC (rev 636)
@@ -394,7 +394,7 @@
selectedObjects = bpy.context.selected_objects
# Create a new object bounds
- if selectedObjects is None:
+ if not selectedObjects:
bounds = addNewObject(scene,
"CloudBounds",
[])
Modified: trunk/py/scripts/addons/space_view3d_panel_measure.py
===================================================================
--- trunk/py/scripts/addons/space_view3d_panel_measure.py 2010-04-23 11:53:35 UTC (rev 635)
+++ trunk/py/scripts/addons/space_view3d_panel_measure.py 2010-04-24 19:35:58 UTC (rev 636)
@@ -156,8 +156,7 @@
# Returns None if more than one (or nothing) is selected.
# Note: Ignores the active object.
def getSingleObject(context):
- if (context.selected_objects
- and len(context.selected_objects) == 1):
+ if len(context.selected_objects) == 1:
return context.selected_objects[0]
return None
@@ -251,17 +250,14 @@
elif (context.mode == 'OBJECT'):
# We are working on object mode.
- if (context.selected_objects
- and len(context.selected_objects) > 2):
+ if len(context.selected_objects) > 2:
return None
- elif (context.selected_objects
- and len(context.selected_objects) == 2):
+ elif len(context.selected_objects) == 2:
# 2 objects selected.
# We measure the distance between the 2 selected objects.
- obj1 = context.selected_objects[0]
- obj2 = context.selected_objects[1]
- obj1_loc = Vector(tuple(obj1.location))
- obj2_loc = Vector(tuple(obj2.location))
+ obj1, obj2 = context.selected_objects
+ obj1_loc = obj1.location.copy()
+ obj2_loc = obj2.location.copy()
return (obj1_loc, obj2_loc, COLOR_GLOBAL)
elif (obj):
@@ -271,8 +267,7 @@
obj_loc = Vector(tuple(obj.location))
return (obj_loc, cur_loc, COLOR_GLOBAL)
- elif (not context.selected_objects
- or len(context.selected_objects) == 0):
+ elif not context.selected_objects:
# Nothing selected.
# We measure the distance from the origin to the 3D cursor.
p1 = Vector(0, 0, 0)
@@ -822,8 +817,7 @@
elif (context.mode == 'OBJECT'):
# We are working on object mode.
- if (context.selected_objects
- and len(context.selected_objects) > 2):
+ if len(context.selected_objects) > 2:
# We have more that 2 objects selected...
row = layout.row()
@@ -833,7 +827,7 @@
if (sce.measure_panel_calc_area):
mesh_objects = [o for o in context.selected_objects
- if (o.type == 'MESH' and o.data)]
+ if (o.type == 'MESH')]
if (len(mesh_objects) > 0):
# ... and at least one of them is a mesh.
@@ -857,13 +851,11 @@
"measure_panel_transform",
expand=True)
- elif (context.selected_objects
- and len(context.selected_objects) == 2):
+ elif len(context.selected_objects) == 2:
# 2 objects selected.
# We measure the distance between the 2 selected objects.
- obj1 = context.selected_objects[0]
- obj2 = context.selected_objects[1]
+ obj1, obj2 = context.selected_objects
# Get the 2 measure points
line = getMeasurePoints(context)
@@ -951,8 +943,7 @@
"measure_panel_transform",
expand=True)
- elif (not context.selected_objects
- or len(context.selected_objects) == 0):
+ elif not context.selected_objects:
# Nothing selected.
# We measure the distance from the origin to the 3D cursor.
More information about the Bf-extensions-cvs
mailing list