UuuNyaa / blender_mmd_tools

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

error no attribute 'proxy' in 3.2 #48

Closed listelin closed 2 years ago

listelin commented 2 years ago

事象

Blender3.2RCでMMD>シーン設定>リジッドボディ>>ワールドを更新を実行するとコンソールに以下のエラーが発生します。

Traceback (most recent call last):
  File "C:\Users\a\AppData\Roaming\Blender Foundation\Blender\3.2\scripts\addons\mmd_tools\operators\rigid_body.py", line 531, in execute
    for r in _references(i):
  File "C:\Users\a\AppData\Roaming\Blender Foundation\Blender\3.2\scripts\addons\mmd_tools\operators\rigid_body.py", line 515, in _references
    if obj.proxy:
AttributeError: 'Object' object has no attribute 'proxy'
Error: Python: Traceback (most recent call last):
  File "C:\Users\a\AppData\Roaming\Blender Foundation\Blender\3.2\scripts\addons\mmd_tools\operators\rigid_body.py", line 531, in execute
    for r in _references(i):
  File "C:\Users\a\AppData\Roaming\Blender Foundation\Blender\3.2\scripts\addons\mmd_tools\operators\rigid_body.py", line 515, in _references
    if obj.proxy:
AttributeError: 'Object' object has no attribute 'proxy'

原因

3.2でProxyが削除されたため https://wiki.blender.org/wiki/Reference/Release_Notes/3.2/Core

参考 Python APIのリリースノートには記述がありませんが、Pythonコンソールでproxyアトリビュートへのアクセスすると3.1.2と3.2RCで以下のように挙動が異なります。

3.1.2

o = bpy.context.active_object o.proxy -> no error

3.2RC

o = bpy.context.active_object o.proxy Traceback (most recent call last): File "", line 1, in AttributeError: 'Object' object has no attribute 'proxy'

One-sixth commented 2 years ago

I've debugged this function and it seems to be a compatibility feature that was only used in versions prior to Blender3. The mmd_tool itself does not use its functions. We just need to simply replace this line https://github.com/UuuNyaa/blender_mmd_tools/blob/main/mmd_tools/operators/rigid_body.py#L515 from

             if obj.proxy:

to

             if getattr(obj, 'proxy', None):

Then the issue can be fixed.

UuuNyaa commented 2 years ago

Thanks for the report and suggestion 😃 I fixed it in e8c2b2b