From f12d2adc870e4bc032f49b9edae85c3b0366b406 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 8 Nov 2018 08:51:03 +1100 Subject: RNA: Object.select_set use boolean, only select - Was setting active state, making it necessary to backup/restore active object in cases where this isn't needed. Existing scripts are explicitly setting the active object when needed. - Use a boolean select arg (toggle selection wasn't used anywhere). - Add an optional view layer argument since scripts should be able to operate outside the user context. --- release/scripts/templates_py/batch_export.py | 6 +++--- release/scripts/templates_py/operator_modal_view3d_raycast.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'release/scripts/templates_py') diff --git a/release/scripts/templates_py/batch_export.py b/release/scripts/templates_py/batch_export.py index a07491742ec..54e5d166c36 100644 --- a/release/scripts/templates_py/batch_export.py +++ b/release/scripts/templates_py/batch_export.py @@ -18,7 +18,7 @@ bpy.ops.object.select_all(action='DESELECT') for obj in selection: - obj.select_set(action='SELECT') + obj.select_set(True) # some exporters only use the active object view_layer.objects.active = obj @@ -31,7 +31,7 @@ for obj in selection: # Can be used for multiple formats # bpy.ops.export_scene.x3d(filepath=fn + ".x3d", use_selection=True) - obj.select_set(action='DESELECT') + obj.select_set(False) print("written:", fn) @@ -39,4 +39,4 @@ for obj in selection: view_layer.objects.active = obj_active for obj in selection: - obj.select_set(action='SELECT') + obj.select_set(True) diff --git a/release/scripts/templates_py/operator_modal_view3d_raycast.py b/release/scripts/templates_py/operator_modal_view3d_raycast.py index 613501143f7..103c13dc1c2 100644 --- a/release/scripts/templates_py/operator_modal_view3d_raycast.py +++ b/release/scripts/templates_py/operator_modal_view3d_raycast.py @@ -67,7 +67,7 @@ def main(context, event): # now we have the object under the mouse cursor, # we could do lots of stuff but for the example just select. if best_obj is not None: - best_obj.select_set(action='SELECT') + best_obj.select_set(True) context.view_layer.objects.active = best_obj -- cgit v1.2.3