I have over 100 objects I need to render out as catalogue style images. What would be the most efficient way to render these all these with the same environment, lighting, material and camera angle?
I've written a very basic AddOn, that does basically what you need.
How to use the AddOn:
The AddOn let's you select your files, puts them one after another in your current scene, and renders them to an outpu-directory.
The AddOn adds a button to the Output-Properties-panel.
By clicking it, you open a file-browser-window.
Select all your files you intend to render and press "Select Files to Render".
Blender then renders all of your selected objects into an "output"-folder, that is created in the same location, that your current .blend-file is located in. The rendered images will be given the objects filename (without the extension). For example "suzanne.obj" may be rendered and saved to "suzanne.png". All other rendersettings are taken from Blender directly.
Besides the .stl-format, .obj, .fbx and .blend files are supported.
Disclaimer: Since I don't have that much experience in writing AddOns, I can't guarantee you, that it works flawlessly. As far as I've seen, it works for me. Code-quality is probably a mess and the AddOn lacks some pleasant UX features as, for example, render-progress. (Blender is not responsive during the rendering!)
How it works / Code-snippets used
This is a more detailed description of what I did, in case you want to create your own script out of it.
An ImportHelper is used to fetch the different files.
I then iterate over each file,
for file in files: filename, extension = os.path.splitext(file.name) filepath = os.path.join(directory, file.name)
create a temporary collection for each object,
collection = bpy.data.collections.new("tmp-collection") scene = context.scene scene.collection.children.link(collection)
and import the object into this collection.
bpy.ops.import_mesh.stl(filepath) for obj in bpy.context.selected_objects: collection.objects.link(obj) bpy.context.scene.collection.objects.unlink(obj)
I then render the scene to the output-folder
scene.render.filepath = "//output/"+filename bpy.ops.render.render(write_still=True)
and delete the temporary-collection with its containing objects.
for c in scene.collection.children: if c.name == "tmp-collection": scene.collection.children.unlink(c) for c in bpy.data.collections: if not c.users: bpy.data.collections.remove(c)