5
$\begingroup$

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?

$\endgroup$
4
  • $\begingroup$ Keep them at the center of the world and switch their visibility in the Outliner (both Hide in Viewport and Disabke in Renders)? Or put each of these objects in a collection and enable/disable these collections? $\endgroup$ – moonboots Jan 15 at 6:30
  • 1
    $\begingroup$ same environment, lighting and camera can be achieved using one file with an object, after each render change the object data to the next object and render, repeat as needed, a script will make this task much less daunting $\endgroup$ – Georges Jan 15 at 9:17
  • $\begingroup$ What is the file format of your objects? .blend or something like .obj, .fbx, ...? $\endgroup$ – Quacksilber Jan 16 at 19:06
  • $\begingroup$ The file format is Stl files $\endgroup$ – user3247041 Jan 17 at 21:38
1
$\begingroup$

I've written a very basic AddOn, that does basically what you need.

example of the AddOns' results


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.

AddOn position

Select all your files you intend to render and press "Select Files to Render".

select your files

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)
$\endgroup$

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.