I am using the multiprocessing package in Python to do renderings in parallel. Meanwhile the rendering is being done I want to import an object into layer X to start rendering it right after the previous renderings are done. However, it seems that I need to switch the scene's active layer to layer X(as also suggested here) and import the object in that layer. This way, the rendering will not be done properly (or at all) as I have to switch layers. It seems that the obj import function also does not provide anything for this.

Using Blender's Python API, does anyone know if it is possible to import an object directly into a specific layer so that the rendering pipeline will continue doing its job?


When a new object is added to a scene, it is always placed on the active layer. It should be easy enough to modify an import script to work around this.

When creating an object by script, that is when not using bpy.ops, you create the mesh data, create a new object that uses the mesh data and then link the object to the scene. It is possible to set the objects layer visibility after linking it to the scene and before updating the scene so that it should not show briefly in the render. Worst case would mean setting the objects data to None, linking it to the scene, placing it on a layer and then setting the data property back.

For the obj importer, line 1297 is where it links the object to the scene. The following addition of one line (base.layers=) seems to work with importing new objects into layer twenty, I haven't tested during rendering or with multiprocessing to check if it might show.

# Create new obj
for obj in new_objects:
    base = scene.objects.link(obj)
    base.layers = [x in [19] for x in range(20)]
    base.select = True

Note that Collada and Alembic support is compiled into blender so would need some more work and a custom build of blender to make this adjustment.

  • $\begingroup$ Thank you. I have already gone through the pain of compiling Blender but I was hoping that there is an easier solution. I was looking at bpy.ops.render.render(); one of its arguments is layer`. Can this argument be helpful in any way? Actually, I was checking the documentation and it seems that it only takes one layer which does not work for me because I render from a couple of layers. $\endgroup$ – Amir Mar 7 '18 at 22:44
  • $\begingroup$ Aren't you importing obj's? You don't have to rebuild blender, just adjust the python file. The layer arg for bpy.ops.render.render refers to render layers - not the same thing as scene layers. $\endgroup$ – sambler Mar 8 '18 at 0:14

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.