1
$\begingroup$

I'm trying to import an OBJ file while rendering an animation, during the frame_change_pre event. The purpose is to stream a sequence of meshes into Blender, one at a time just before each render. I've successfully done this in Blender 3.6 and earlier using the Legacy OBJ importer (bpy.ops.importer_scene.obj()), but I'm running into problems with Blender 4.0 and the new OBJ importer (bpy.ops.wm.obj_import()). I keep getting the error:

RuntimeError: Operator bpy.ops.wm.obj_import.poll() failed, context is incorrect

Looking at the Blender source code (source/blender/editors/io/io_obj.cc#L488), I've found that the poll function is the WM_operator_winactive function. This function, as far as I can tell, simply checks for an active window, but correct me if I'm wrong.

I've tried using the bpy.context.temp_override() function with no success. I'm not sure how to override the context. How can I override the context for this specific case? Or what workarounds might exist?

$\endgroup$
4
  • $\begingroup$ There are no Blender developers here, nor does anyone here work for or have any association with the Blender Foundation. Since that addon is now written in C++ which we can't help with here, rather than python, I'd suggest you ask in a Blender developer forum, maybe at blender.chat/home . $\endgroup$
    – John Eason
    Commented Nov 3, 2023 at 17:46
  • 1
    $\begingroup$ @JohnEason I don't see why that means I can't ask the question here. $\endgroup$
    – Justin
    Commented Nov 3, 2023 at 18:02
  • $\begingroup$ I didn't say that you couldn't just that you're more likely to get an answer in a developer forum. $\endgroup$
    – John Eason
    Commented Nov 3, 2023 at 19:11
  • $\begingroup$ I'm unfamiliar with Stop Motion OBJ but I was running into problems with bpy.ops.wm.obj_import() in 4.0 too, but now with 4.1 it's working for me, though I'm not sure if something changed. If the problem still persists, then I would suggest to setup a simple for-loop that imports the next obj from a sequence and then renders an image on each loop, because the stream function may have been written to work with the legacy importer, and there are still some differences between the two importers. At the very least, this might help you debug the issue, I hope. $\endgroup$
    – coCoKNIght
    Commented May 3 at 11:34

0

You must log in to answer this question.

Browse other questions tagged .