Context is incorrect when importing different collada files

Hi there,

I’m using bpy 2.79 as a django module for my project and I encounter some difficulties with bpy.ops.wm.collada_import function.

What I do

When a certain django view (GET Rest Api call) is called :

  • I first remove all objects is the scene with
  • I load a .dae (Collada) file with bpy.ops.wm.collada_import
  • Then the only operations I do are getting objects positions and making some ray_casting (with bpy.context.scene.ray_cast)

When the same view is called, I try to do the same thing as above.

What happens

If it’s the same file that I try to import, there is no problem it work like in the first time.
If it’s a different file (still Collada file) I always get:

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

What I already tried

  • Overriding context with similar context as the first (working) one
  • Create a new “clean” scene before each import

Some additionals infos

  • I have to stay with bpy 2.79
  • I have to stay in the django framework
  • Using the same Collada file but with different filepath work as well
  • Same multiple imports of different files works if done through python command-lines
1 Like

I have the same problem but with pyside2 app instead. Hopefully someone can help.