Fix T57776: Error when adding a Torus to the scene.

Not all Object.select_set() cases had been updated to new API... Tsst. ;)
This commit is contained in:
Bastien Montagne 2018-11-11 11:22:38 +01:00
parent 0dea135a36
commit fd65ebf39a
Notes: blender-bot 2023-02-14 10:37:49 +01:00
Referenced by issue #57776, Error when adding a Torus to the scene
6 changed files with 17 additions and 17 deletions

View File

@ -125,7 +125,7 @@ def object_data_add(context, obdata, operator=None, name=None):
scene_collection = layer_collection.collection
for ob in layer.objects:
ob.select_set(action='DESELECT')
ob.select_set(False)
if name is None:
name = "Object" if obdata is None else obdata.name
@ -133,7 +133,7 @@ def object_data_add(context, obdata, operator=None, name=None):
obj_act = layer.objects.active
obj_new = bpy.data.objects.new(name, obdata)
scene_collection.objects.link(obj_new)
obj_new.select_set(action='SELECT')
obj_new.select_set(True)
obj_new.matrix_world = add_object_align_init(context, operator)
# XXX
@ -155,10 +155,10 @@ def object_data_add(context, obdata, operator=None, name=None):
if obj_act and obj_act.mode == 'EDIT' and obj_act.type == obj_new.type:
bpy.ops.mesh.select_all(action='DESELECT')
obj_act.select_set(action='SELECT')
obj_act.select_set(True)
bpy.ops.object.mode_set(mode='OBJECT')
obj_act.select_set(action='SELECT')
obj_act.select_set(True)
scene.update() # apply location
# layer.objects.active = obj_new

View File

@ -237,7 +237,7 @@ class CLIP_OT_track_to_empty(Operator):
ob = bpy.data.objects.new(name=track.name, object_data=None)
context.collection.objects.link(ob)
ob.select_set(action='SELECT')
ob.select_set(True)
context.view_layer.objects.active = ob
for con in ob.constraints:
@ -516,7 +516,7 @@ class CLIP_OT_constraint_to_fcurve(Operator):
# XXX, should probably use context.selected_editable_objects
# since selected objects can be from a lib or in hidden layer!
for ob in scene.objects:
if ob.select_set(action='SELECT'):
if ob.select_set(True):
self._bake_object(scene, ob)
return {'FINISHED'}

View File

@ -92,7 +92,7 @@ class SelectPattern(Operator):
if item_parent is not None:
item_parent.select_tail = True
else:
item.select_set(action='SELECT')
item.select_set(True)
return {'FINISHED'}
@ -139,7 +139,7 @@ class SelectCamera(Operator):
bpy.ops.object.select_all(action='DESELECT')
view_layer.objects.active = camera
# camera.hide = False # XXX TODO where is this now?
camera.select_set(action='SELECT')
camera.select_set(True)
return {'FINISHED'}
return {'CANCELLED'}
@ -205,7 +205,7 @@ class SelectHierarchy(Operator):
bpy.ops.object.select_all(action='DESELECT')
for obj in select_new:
obj.select_set(action='SELECT')
obj.select_set(True)
view_layer.objects.active = act_new
return {'FINISHED'}
@ -646,8 +646,8 @@ class MakeDupliFace(Operator):
ob_new.use_dupli_faces_scale = True
ob_new.dupli_faces_scale = 1.0 / SCALE_FAC
ob_inst.select_set(action='SELECT')
ob_new.select_set(action='SELECT')
ob_inst.select_set(True)
ob_new.select_set(True)
def execute(self, context):
self._main(context)

View File

@ -65,7 +65,7 @@ class CopyRigidbodySettings(Operator):
# deselect all but mesh objects
for o in context.selected_objects:
if o.type != 'MESH':
o.select_set(action='DESELECT')
o.select_set(False)
elif o.rigid_body is None:
# Add rigidbody to object!
view_layer.objects.active = o
@ -127,7 +127,7 @@ class BakeToKeyframes(Operator):
# filter objects selection
for obj in context.selected_objects:
if not obj.rigid_body or obj.rigid_body.type != 'ACTIVE':
obj.select_set(action='DESELECT')
obj.select_set(False)
objects = context.selected_objects
@ -266,7 +266,7 @@ class ConnectRigidBodies(Operator):
ob.location = loc
context.scene.objects.link(ob)
context.view_layer.objects.active = ob
ob.select_set(action='SELECT')
ob.select_set(True)
bpy.ops.rigidbody.constraint_add()
con_obj = context.active_object
@ -311,7 +311,7 @@ class ConnectRigidBodies(Operator):
# restore selection
bpy.ops.object.select_all(action='DESELECT')
for obj in objects:
obj.select_set(action='SELECT')
obj.select_set(True)
view_layer.objects.active = obj_act
return {'FINISHED'}
else:

View File

@ -46,7 +46,7 @@ class UnitTesting(ViewLayerTesting):
if mode == 'DUPLICATE':
# assuming the latest layer is the active layer
bpy.ops.object.select_all(action='DESELECT')
three_c.select_set(action='SELECT')
three_c.select_set(True)
bpy.ops.object.duplicate()
elif mode == 'NAMED':

View File

@ -416,7 +416,7 @@ class ViewLayerTesting(unittest.TestCase):
elif del_mode == 'OPERATOR':
bpy.context.scene.update() # update depsgraph
bpy.ops.object.select_all(action='DESELECT')
ob.select_set(action='SELECT')
ob.select_set(True)
self.assertTrue(ob.select_get())
bpy.ops.object.delete()