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.
This commit is contained in:
Campbell Barton
2018-11-08 08:51:03 +11:00
parent c121bc6219
commit f12d2adc87
13 changed files with 27 additions and 42 deletions

View File

@@ -38,7 +38,7 @@ class UnitTesting(ViewLayerTesting):
layer_collection_mom.enabled = False
bpy.context.scene.update() # update depsgraph
cube.select_set('SELECT')
cube.select_set(True)
self.assertTrue(cube.visible_get(), "Cube should be visible")
self.assertTrue(cube.select_get(), "Cube should be selected")

View File

@@ -36,7 +36,7 @@ class UnitTesting(ViewLayerTesting):
layer_collection_mom = layer.collections.link(scene_collection_mom)
layer_collection_kid = layer.collections.link(scene_collection_kid)
bpy.context.scene.update() # update depsgraph
cube.select_set('SELECT')
cube.select_set(True)
layer_collection_mom.collections[layer_collection_kid.name].enabled = False
layer_collection_kid.enabled = False

View File

@@ -38,7 +38,7 @@ class UnitTesting(ViewLayerTesting):
layer_collection_mom.enabled = True
bpy.context.scene.update() # update depsgraph
cube.select_set('SELECT')
cube.select_set(True)
self.assertTrue(cube.visible_get(), "Cube should be visible")
self.assertTrue(cube.select_get(), "Cube should be selected")

View File

@@ -39,7 +39,7 @@ class UnitTesting(ViewLayerTesting):
layer_collection_mom.enabled = True
bpy.context.scene.update() # update depsgraph
cube.select_set('SELECT')
cube.select_set(True)
layer_collection_mom.collections[layer_collection_kid.name].selectable = False
bpy.context.scene.update() # update depsgraph

View File

@@ -37,7 +37,7 @@ class UnitTesting(ViewLayerTesting):
layer_collection_kid = layer.collections.link(scene_collection_kid)
layer_collection_mom.enabled = True
cube.select_set('SELECT')
cube.select_set(True)
layer_collection_mom.collections[layer_collection_kid.name].selectable = False
layer_collection_kid.enabled = False

View File

@@ -51,9 +51,9 @@ class UnitTesting(ViewLayerTesting):
# we could just pass an overridden context
# but let's do it the old fashion way
view_layer.objects.active = ob
ob.select_set('SELECT')
ob.select_set(True)
self.assertTrue(ob.select_get())
empty.select_set('DESELECT')
empty.select_set(False)
self.assertFalse(empty.select_get())
# update depsgraph

View File

@@ -36,7 +36,7 @@ class UnitTesting(ViewLayerTesting):
master_collection.collections[0])
view_layer.collections.link(master_collection)
ob.select_set('SELECT')
ob.select_set(True)
# update depsgraph
scene.update()

View File

@@ -26,7 +26,7 @@ class UnitTesting(ViewLayerTesting):
layer = bpy.context.view_layer
original_cube = layer.objects.get('Cube')
original_cube.select_set('SELECT')
original_cube.select_set(True)
self.assertTrue(original_cube.select_get())
bpy.ops.scene.new(type='FULL_COPY')