So far I have the code:

scene = bpy.context.scene
import_avHat1 = bpy.ops.import_scene.obj(filepath=avatarHat_1)
import_avHat2 = bpy.ops.import_scene.obj(filepath=avatarHat_2)
import_avHat3 = bpy.ops.import_scene.obj(filepath=avatarHat_3)
hats = bpy.context.selected_objects[:]

for obj in hats:
    # print the name of the current obj
    print (obj.name)
    bpy.context.view_layer.objects.active = obj

obj_camera = bpy.context.scene.camera
scene.render.image_settings.file_format = 'PNG'
scene.render.filepath = "~/mark/renderOutput.png"
bpy.ops.render.render(write_still = 1)

It only renders the first hat and I get no errors importing the others. What should I do? This occurs in blender 2.8.

  • $\begingroup$ what if you execute the code line by line in the Python console. Do the import_avHatn variables have the correct meshes? $\endgroup$
    – rob
    Aug 20, 2019 at 18:51
  • 1
    $\begingroup$ I've done that and they do. $\endgroup$ Aug 20, 2019 at 18:54
  • $\begingroup$ Oh nevermind they don't have the correct meshes. If you post that as an answer I'll mark it. $\endgroup$ Aug 20, 2019 at 18:59
  • $\begingroup$ lol somebody upvoted my question. it works! i'm just an idiot. $\endgroup$ Aug 20, 2019 at 19:00

1 Answer 1


Manually debug your code one line at a time by pasting it into the Python console and checking the results.


Not the answer you're looking for? Browse other questions tagged .