diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-04-24 23:35:58 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-04-24 23:35:58 +0400 |
commit | 9c0724824822b9fec5562081f6e3d5d1f26c732d (patch) | |
tree | 542280cba7877a12f1d64cd82ef2dbc80d2e652f | |
parent | b1337de16a1220947a17e41d0b5d78da91c67b4a (diff) |
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.
-rw-r--r-- | add_edit_object_parameters.py | 1 | ||||
-rw-r--r-- | io_anim_camera.py | 2 | ||||
-rw-r--r-- | mesh_relax.py | 11 | ||||
-rw-r--r-- | object_cloud_gen.py | 2 | ||||
-rw-r--r-- | space_view3d_panel_measure.py | 33 |
5 files changed, 19 insertions, 30 deletions
diff --git a/add_edit_object_parameters.py b/add_edit_object_parameters.py index b30f941d..23d63e63 100644 --- a/add_edit_object_parameters.py +++ b/add_edit_object_parameters.py @@ -174,7 +174,6 @@ class VIEW3D_OT_edit_object_parameters(bpy.types.Panel): # 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): diff --git a/io_anim_camera.py b/io_anim_camera.py index 03783330..5e4e848a 100644 --- a/io_anim_camera.py +++ b/io_anim_camera.py @@ -103,7 +103,7 @@ def writeCameras(context, path, frame_start, frame_end, only_selected=False): 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) diff --git a/mesh_relax.py b/mesh_relax.py index 0d7e756a..9211659a 100644 --- a/mesh_relax.py +++ b/mesh_relax.py @@ -50,14 +50,13 @@ import bpy 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! diff --git a/object_cloud_gen.py b/object_cloud_gen.py index 85c01c43..1fa76fc7 100644 --- a/object_cloud_gen.py +++ b/object_cloud_gen.py @@ -394,7 +394,7 @@ class GenerateCloud(bpy.types.Operator): selectedObjects = bpy.context.selected_objects # Create a new object bounds - if selectedObjects is None: + if not selectedObjects: bounds = addNewObject(scene, "CloudBounds", []) diff --git a/space_view3d_panel_measure.py b/space_view3d_panel_measure.py index e4cfe1be..35ffffbc 100644 --- a/space_view3d_panel_measure.py +++ b/space_view3d_panel_measure.py @@ -156,8 +156,7 @@ COLOR_GLOBAL = (0.0, 0.0, 1.0, 0.8) # 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 @@ def getMeasurePoints(context): 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 @@ def getMeasurePoints(context): 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 @@ class VIEW3D_PT_measure(bpy.types.Panel): 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 @@ class VIEW3D_PT_measure(bpy.types.Panel): 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 @@ class VIEW3D_PT_measure(bpy.types.Panel): "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 @@ class VIEW3D_PT_measure(bpy.types.Panel): "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. |