PyAPI: remove context override argument from bpy.ops
Remove deprecated context override argument to operator execution and poll() method in favor of context.temp_override().
This commit is contained in:
@@ -80,7 +80,8 @@ class EulerFilterTest(AbstractAnimationTest, unittest.TestCase):
|
||||
self.assertEqualAngle(111.422, fcu_rot[1], 23)
|
||||
self.assertEqualAngle(76.5996, fcu_rot[2], 23)
|
||||
|
||||
bpy.ops.graph.euler_filter(self.get_context())
|
||||
with bpy.context.temp_override(**self.get_context()):
|
||||
bpy.ops.graph.euler_filter()
|
||||
|
||||
# Keyframes before the "jump". These shouldn't be touched by the filter.
|
||||
self.assertEqualAngle(-87.5742, fcu_rot[0], 22)
|
||||
@@ -105,7 +106,8 @@ class EulerFilterTest(AbstractAnimationTest, unittest.TestCase):
|
||||
self.assertEqualAngle(720, fcu_rot[0], 16)
|
||||
self.assertEqualAngle(72, fcu_rot[1], 22)
|
||||
|
||||
bpy.ops.graph.euler_filter(self.get_context())
|
||||
with bpy.context.temp_override(**self.get_context()):
|
||||
bpy.ops.graph.euler_filter()
|
||||
|
||||
# Keyframes before the "jump". These shouldn't be touched by the filter.
|
||||
self.assertEqualAngle(360, fcu_rot[0], 15)
|
||||
|
||||
@@ -122,8 +122,9 @@ class ChildOfTest(AbstractConstraintTests):
|
||||
))
|
||||
self.matrix_test('Child Of.object.owner', initial_matrix)
|
||||
|
||||
context = self.constraint_context('Child Of', owner_name='Child Of.object.owner')
|
||||
bpy.ops.constraint.childof_set_inverse(context, constraint='Child Of')
|
||||
context_override = self.constraint_context('Child Of', owner_name='Child Of.object.owner')
|
||||
with bpy.context.temp_override(**context_override):
|
||||
bpy.ops.constraint.childof_set_inverse(constraint='Child Of')
|
||||
self.matrix_test('Child Of.object.owner', Matrix((
|
||||
(0.9992385506629944, 0.019844001159071922, -0.03359175845980644, 0.10000011324882507),
|
||||
(-0.01744179055094719, 0.997369647026062, 0.07035345584154129, 0.1999998837709427),
|
||||
@@ -131,7 +132,8 @@ class ChildOfTest(AbstractConstraintTests):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)))
|
||||
|
||||
bpy.ops.constraint.childof_clear_inverse(context, constraint='Child Of')
|
||||
with bpy.context.temp_override(**context_override):
|
||||
bpy.ops.constraint.childof_clear_inverse(constraint='Child Of')
|
||||
self.matrix_test('Child Of.object.owner', initial_matrix)
|
||||
|
||||
def test_object_rotation_only(self):
|
||||
@@ -149,8 +151,9 @@ class ChildOfTest(AbstractConstraintTests):
|
||||
))
|
||||
self.matrix_test('Child Of.object.owner', initial_matrix)
|
||||
|
||||
context = self.constraint_context('Child Of', owner_name='Child Of.object.owner')
|
||||
bpy.ops.constraint.childof_set_inverse(context, constraint='Child Of')
|
||||
context_override = self.constraint_context('Child Of', owner_name='Child Of.object.owner')
|
||||
with bpy.context.temp_override(**context_override):
|
||||
bpy.ops.constraint.childof_set_inverse(constraint='Child Of')
|
||||
self.matrix_test('Child Of.object.owner', Matrix((
|
||||
(0.9992386102676392, 0.019843975082039833, -0.033591702580451965, 0.10000000149011612),
|
||||
(-0.017441781237721443, 0.9973695874214172, 0.0703534483909607, 0.20000000298023224),
|
||||
@@ -158,7 +161,8 @@ class ChildOfTest(AbstractConstraintTests):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)))
|
||||
|
||||
bpy.ops.constraint.childof_clear_inverse(context, constraint='Child Of')
|
||||
with bpy.context.temp_override(**context_override):
|
||||
bpy.ops.constraint.childof_clear_inverse(constraint='Child Of')
|
||||
self.matrix_test('Child Of.object.owner', initial_matrix)
|
||||
|
||||
def test_object_no_x_axis(self):
|
||||
@@ -177,8 +181,9 @@ class ChildOfTest(AbstractConstraintTests):
|
||||
))
|
||||
self.matrix_test('Child Of.object.owner', initial_matrix)
|
||||
|
||||
context = self.constraint_context('Child Of', owner_name='Child Of.object.owner',)
|
||||
bpy.ops.constraint.childof_set_inverse(context, constraint='Child Of')
|
||||
context_override = self.constraint_context('Child Of', owner_name='Child Of.object.owner',)
|
||||
with bpy.context.temp_override(**context_override):
|
||||
bpy.ops.constraint.childof_set_inverse(constraint='Child Of')
|
||||
self.matrix_test('Child Of.object.owner', Matrix((
|
||||
(0.9992386102676392, 0.019843991845846176, -0.03359176218509674, 0.10000000149011612),
|
||||
(-0.017441775649785995, 0.997369647026062, 0.0703534483909607, 0.2000001221895218),
|
||||
@@ -186,7 +191,8 @@ class ChildOfTest(AbstractConstraintTests):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)))
|
||||
|
||||
bpy.ops.constraint.childof_clear_inverse(context, constraint='Child Of')
|
||||
with bpy.context.temp_override(**context_override):
|
||||
bpy.ops.constraint.childof_clear_inverse(constraint='Child Of')
|
||||
self.matrix_test('Child Of.object.owner', initial_matrix)
|
||||
|
||||
def test_bone_simple_parent(self):
|
||||
@@ -199,8 +205,9 @@ class ChildOfTest(AbstractConstraintTests):
|
||||
))
|
||||
self.matrix_test('Child Of.armature.owner', initial_matrix)
|
||||
|
||||
context = self.constraint_context('Child Of', owner_name='Child Of.armature.owner')
|
||||
bpy.ops.constraint.childof_set_inverse(context, constraint='Child Of')
|
||||
context_override = self.constraint_context('Child Of', owner_name='Child Of.armature.owner')
|
||||
with bpy.context.temp_override(**context_override):
|
||||
bpy.ops.constraint.childof_set_inverse(constraint='Child Of')
|
||||
|
||||
self.matrix_test('Child Of.armature.owner', Matrix((
|
||||
(0.9992386102676392, 0.019843988120555878, -0.03359176218509674, 0.8358089923858643),
|
||||
@@ -209,7 +216,8 @@ class ChildOfTest(AbstractConstraintTests):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)))
|
||||
|
||||
bpy.ops.constraint.childof_clear_inverse(context, constraint='Child Of')
|
||||
with bpy.context.temp_override(**context_override):
|
||||
bpy.ops.constraint.childof_clear_inverse(constraint='Child Of')
|
||||
self.matrix_test('Child Of.armature.owner', initial_matrix)
|
||||
|
||||
def test_bone_owner(self):
|
||||
@@ -222,8 +230,9 @@ class ChildOfTest(AbstractConstraintTests):
|
||||
))
|
||||
self.bone_matrix_test('Child Of.bone.owner', 'Child Of.bone', initial_matrix)
|
||||
|
||||
context = self.bone_constraint_context('Child Of', owner_name='Child Of.bone.owner')
|
||||
bpy.ops.constraint.childof_set_inverse(context, constraint='Child Of', owner='BONE')
|
||||
context_override = self.bone_constraint_context('Child Of', owner_name='Child Of.bone.owner')
|
||||
with bpy.context.temp_override(**context_override):
|
||||
bpy.ops.constraint.childof_set_inverse(constraint='Child Of', owner='BONE')
|
||||
|
||||
self.bone_matrix_test('Child Of.bone.owner', 'Child Of.bone', Matrix((
|
||||
(0.9659260511398315, 0.2588191032409668, 4.656613428188905e-10, -2.999999761581421),
|
||||
@@ -232,7 +241,8 @@ class ChildOfTest(AbstractConstraintTests):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)))
|
||||
|
||||
bpy.ops.constraint.childof_clear_inverse(context, constraint='Child Of', owner='BONE')
|
||||
with bpy.context.temp_override(**context_override):
|
||||
bpy.ops.constraint.childof_clear_inverse(constraint='Child Of', owner='BONE')
|
||||
self.bone_matrix_test('Child Of.bone.owner', 'Child Of.bone', initial_matrix)
|
||||
|
||||
def test_vertexgroup_simple_parent(self):
|
||||
@@ -245,8 +255,9 @@ class ChildOfTest(AbstractConstraintTests):
|
||||
))
|
||||
self.matrix_test('Child Of.vertexgroup.owner', initial_matrix)
|
||||
|
||||
context = self.constraint_context('Child Of', owner_name='Child Of.vertexgroup.owner')
|
||||
bpy.ops.constraint.childof_set_inverse(context, constraint='Child Of')
|
||||
context_override = self.constraint_context('Child Of', owner_name='Child Of.vertexgroup.owner')
|
||||
with bpy.context.temp_override(**context_override):
|
||||
bpy.ops.constraint.childof_set_inverse(constraint='Child Of')
|
||||
|
||||
self.matrix_test('Child Of.vertexgroup.owner', Matrix((
|
||||
(0.9992386102676392, 0.019843988120555878, -0.03359176218509674, 0.10000000149011612),
|
||||
@@ -255,7 +266,8 @@ class ChildOfTest(AbstractConstraintTests):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)))
|
||||
|
||||
bpy.ops.constraint.childof_clear_inverse(context, constraint='Child Of')
|
||||
with bpy.context.temp_override(**context_override):
|
||||
bpy.ops.constraint.childof_clear_inverse(constraint='Child Of')
|
||||
self.matrix_test('Child Of.vertexgroup.owner', initial_matrix)
|
||||
|
||||
|
||||
@@ -272,8 +284,9 @@ class ObjectSolverTest(AbstractConstraintTests):
|
||||
))
|
||||
self.matrix_test('Object Solver.owner', initial_matrix)
|
||||
|
||||
context = self.constraint_context('Object Solver')
|
||||
bpy.ops.constraint.objectsolver_set_inverse(context, constraint='Object Solver')
|
||||
context_override = self.constraint_context('Object Solver')
|
||||
with bpy.context.temp_override(**context_override):
|
||||
bpy.ops.constraint.objectsolver_set_inverse(constraint='Object Solver')
|
||||
self.matrix_test('Object Solver.owner', Matrix((
|
||||
(0.9992387294769287, 0.019843989983201027, -0.03359176591038704, 0.10000025480985641),
|
||||
(-0.017441747710108757, 0.9973697662353516, 0.07035345584154129, 0.1999993920326233),
|
||||
@@ -281,7 +294,8 @@ class ObjectSolverTest(AbstractConstraintTests):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)))
|
||||
|
||||
bpy.ops.constraint.objectsolver_clear_inverse(context, constraint='Object Solver')
|
||||
with bpy.context.temp_override(**context_override):
|
||||
bpy.ops.constraint.objectsolver_clear_inverse(constraint='Object Solver')
|
||||
self.matrix_test('Object Solver.owner', initial_matrix)
|
||||
|
||||
|
||||
|
||||
@@ -592,15 +592,17 @@ class SpecMeshTest(MeshTest):
|
||||
elif modifier.type == 'CLOTH' or modifier.type == 'SOFT_BODY':
|
||||
test_object.modifiers[test_modifier_name].point_cache.frame_end = frame_end
|
||||
override_setting = modifier.point_cache
|
||||
override = {'scene': scene, 'active_object': test_object, 'point_cache': override_setting}
|
||||
bpy.ops.ptcache.bake(override, bake=True)
|
||||
context_override = {'scene': scene, 'active_object': test_object, 'point_cache': override_setting}
|
||||
with bpy.context.temp_override(**context_override):
|
||||
bpy.ops.ptcache.bake(bake=True)
|
||||
break
|
||||
|
||||
elif modifier.type == 'DYNAMIC_PAINT':
|
||||
dynamic_paint_setting = modifier.canvas_settings.canvas_surfaces.active
|
||||
override_setting = dynamic_paint_setting.point_cache
|
||||
override = {'scene': scene, 'active_object': test_object, 'point_cache': override_setting}
|
||||
bpy.ops.ptcache.bake(override, bake=True)
|
||||
context_override = {'scene': scene, 'active_object': test_object, 'point_cache': override_setting}
|
||||
with bpy.context.temp_override(**context_override):
|
||||
bpy.ops.ptcache.bake(bake=True)
|
||||
break
|
||||
|
||||
def _apply_particle_system(self, test_object, particle_sys_spec: ParticleSystemSpec):
|
||||
|
||||
Reference in New Issue
Block a user