【bug】blender AttributeError: Calling operator “bpy.ops.import_scene.obj” error, could not be found
环境
blender 4.3.0
问题详情
import bpy
bpy.ops.import_scene.obj(filepath="D:/3dfile/car.obj")
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
File "C:\Program Files\Blender Foundation\Blender 4.3\4.3\scripts\modules\bpy\ops.py", line 109, in __call__
ret = _op_call(self.idname_py(), kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: Calling operator "bpy.ops.import_scene.obj" error, could not be found
这是在使用blender 软件通过Python脚本导入obj
格式3d模型时弹出的错误。
错误原因是该API在blender 4.x
已经不存在了,改为bpy.ops.wm.obj_import(filepath=obj_path)
了。
解决方法
将导入函数改为
import bpy
bpy.ops.wm.obj_import(filepath="D:/3dfile/car.obj")
.