UuuNyaa / blender_mmd_tools

MMD Tools is a blender addon for importing/exporting Models and Motions of MikuMikuDance.
GNU General Public License v3.0
1.91k stars 91 forks source link

According to the error message, it seems that the bpy.ops.ptcache.bake() function only supports 1 or 2 arguments for the execution context. However, the code you shared does not explicitly show how many arguments are being passed. #131

Open lxrchen opened 5 months ago

lxrchen commented 5 months ago

Python: Traceback (most recent call last): File "C:\Users\23026\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\mmd_tools\operators\rigid_body.py", line 294, in execute bpy.ops.ptcache.bake(override, "INVOKE_DEFAULT", bake=True) File "E:\Blender\4.0\scripts\modules\bpy\ops.py", line 106, in call C_exec, C_undo = _BPyOpsSubModOp._parse_args(args) File "E:\Blender\4.0\scripts\modules\bpy\ops.py", line 60, in _parse_args raise ValueError("1-2 args execution context is supported") ValueError: 1-2 args execution context is supported

Yusarina commented 5 months ago

Personally I would not be using MMD tools on Blender 4.0, as the developer as stated in other issues, there don't plan on releasing it unto the LTS for 4.2 comes out.

see this for more info, key word is it's under development.

There for this means the blender-v4 branch is not stable and may not be unto later this year.

MostW commented 4 months ago

https://blender.stackexchange.com/questions/305388/valueerror-1-2-args-execution-context-is-supported-on-call-to-bpy-ops-outlin

https://docs.blender.org/api/current/bpy.ops.html#overriding-context

It was because bpy changes api, so I change the blender-v4 branch code and install mmd_tool again , and it works.

file path: mmd_tools\operators\rigid_body.py,

 def execute(self, context: bpy.types.Context):
        override: Dict = context.copy()
        override.update({"scene": context.scene, "point_cache": context.scene.rigidbody_world.point_cache})

        # origin code 
        # bpy.ops.ptcache.bake(override, "INVOKE_DEFAULT", bake=True)

        #  new code
        with bpy.context.temp_override(**override):
            bpy.ops.ptcache.bake("INVOKE_DEFAULT", bake=True)

        return {"FINISHED"}
def execute(self, context: bpy.types.Context):
        override: Dict = context.copy()
        override.update({"scene": context.scene, "point_cache": context.scene.rigidbody_world.point_cache})

        # origin  code
        # bpy.ops.ptcache.free_bake(override, "INVOKE_DEFAULT")

        # new code
        with bpy.context.temp_override(**override):
            bpy.ops.ptcache.free_bake("INVOKE_DEFAULT")

        return {"FINISHED"}
UuuNyaa commented 2 months ago

Please try MMD Tools v4.x and give us feedback.