Quite a simple question I hope, I've been tearing my hair out with it for over a day now though. I'm trying to write a background python script that will import an alembic and then perform certain actions on it.

I can get the alembic to import by calling bpy.ops.wm.alembic_import with the filepath, however this import appears to occur in a separate thread which means that the code I immediately move on to still sees an empty scene.

Is there a way to make the python script execution wait until the import is finished, or insert a callback that will be called once the import is finished? I've tried the load_post and scene_update_post callbacks with no luck.


bpy.ops.wm.alembic_import operator provides a property called as_background_job which defaults to True. In that case the alembic import will happen asynchronously.

You can override the default behavior by passing a False value, in which case the import happens synchronously (blocking Blender)

bpy.ops.wm.alembic_import(filepath='....abc', as_background_job=False)
|improve this answer|||||

I had the same issue,

This is my current solution:

import bpy, time

#get size of total scene:
sceneSize = len(bpy.data.objects)

#do my import:

#wait for scene size to change:
elapsed = 0.0
maxTime = 10
while(sceneSize==len(bpy.data.objects) and elapsed < maxTime):
    elapsed += 0.2

#do something with imported thing:
bpy.context.scene.camera = bpy.data.objects["RenderCam"]

basically keep checking the size of the scene until it changes - then assume that the import is complete.

I welcome a better solution if anyone knows one.

|improve this answer|||||
  • $\begingroup$ Turns out this only works for small imports (eg cameras). if I try to import an abc with lots of stuff it ends to early..... $\endgroup$ – Puerestvfx Jan 4 '17 at 14:13
  • 1
    $\begingroup$ Maybe read the alembic file for the object count first, then use that as a gauge for when to proceed? $\endgroup$ – cmomoney Feb 8 '17 at 13:33
  • $\begingroup$ That is not a predictable and reliable way. I have added an answer which overrides the 'as_background_job' alembic_import operator property. $\endgroup$ – satishgoda Jul 27 '17 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.