Skip to content

AttributeError: Calling operator "bpy.ops.import_scene.obj" error, could not be found in blender-4.1.1 #3

@matteogrechi

Description

@matteogrechi

Good evening,
Running scripts/teaser.py with Blender 4.1.1 gets me the error:

Blender 4.1.1 (hash e1743a0317bc built 2024-04-15 23:47:45)
Traceback (most recent call last):
  File "./scripts/teaser.py", line 57, in <module>
    render_teaser(args)
  File "./scripts/teaser.py", line 30, in render_teaser
    bunny = load_obj("docs/bunny.obj", "bunny", center=True)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "./blender-4.1.1-linux-x64/4.1/python/lib/python3.11/site-packages/pyblend/object.py", line 59, in load_obj
    bpy.ops.import_scene.obj(filepath=obj_root)
  File "./blender-4.1.1-linux-x64/4.1/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

As it turn out bpy.ops.import_scene.obj was removed at bpy==4.
bpy.ops.wm.obj_import(filepath='') shall be used instead.
See AttributeError: Calling operator "bpy.ops.import_scene.obj" error, could not be found

I think this is fixable by correcting pyblend/object.py with the new obj_import function.
I don't know if this will break retro-compatibility.

Thank you for your attention and job!
Greetings

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions