Skip to content

Commit

Permalink
Fix context override method for bpy.ops #146
Browse files Browse the repository at this point in the history
  • Loading branch information
UuuNyaa committed Apr 18, 2024
1 parent 83e645d commit c2160f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions mmd_tools/core/morph.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def copy_uv_morph_vertex_groups(obj, src_name, dest_name):

for vg_name in tuple(i[0].name for i in FnMorph.get_uv_morph_vertex_groups(obj, src_name)):
obj.vertex_groups.active = obj.vertex_groups[vg_name]
override = {"object": obj, "window": bpy.context.window, "region": bpy.context.region}
bpy.ops.object.vertex_group_copy(override)
with bpy.context.temp_override(object=obj, window=bpy.context.window, region=bpy.context.region):
bpy.ops.object.vertex_group_copy()
obj.vertex_groups.active.name = vg_name.replace(src_name, dest_name)

@staticmethod
Expand Down
10 changes: 4 additions & 6 deletions mmd_tools/operators/rigid_body.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,8 @@ class RigidBodyBake(bpy.types.Operator):
bl_options = {"REGISTER", "UNDO", "INTERNAL"}

def execute(self, context: bpy.types.Context):
override: Dict = context.copy()
override.update({"scene": context.scene, "point_cache": context.scene.rigidbody_world.point_cache})
bpy.ops.ptcache.bake(override, "INVOKE_DEFAULT", bake=True)
with bpy.context.temp_override(scene=context.scene, point_cache=context.scene.rigidbody_world.point_cache):
bpy.ops.ptcache.bake("INVOKE_DEFAULT", bake=True)

return {"FINISHED"}

Expand All @@ -317,9 +316,8 @@ class RigidBodyDeleteBake(bpy.types.Operator):
bl_options = {"REGISTER", "UNDO", "INTERNAL"}

def execute(self, context: bpy.types.Context):
override: Dict = context.copy()
override.update({"scene": context.scene, "point_cache": context.scene.rigidbody_world.point_cache})
bpy.ops.ptcache.free_bake(override, "INVOKE_DEFAULT")
with bpy.context.temp_override(scene=context.scene, point_cache=context.scene.rigidbody_world.point_cache):
bpy.ops.ptcache.free_bake("INVOKE_DEFAULT")

return {"FINISHED"}

Expand Down

0 comments on commit c2160f0

Please sign in to comment.