import bpy for i in range(302, 1440): #Import meshpath_1 ="/home/cloud-user/vr/strings/strings_""%04d"".stl" % i meshpath_2 ="/home/cloud-user/vr/monopoles/monopoles_""%04d"".stl" % i imagepath = "/home/cloud-user/vr/test_""%04d"".png" % i bpy.ops.import_mesh.stl(filepath=meshpath_1) bpy.ops.import_mesh.stl(filepath=meshpath_2) strings = "Strings ""%04d" % i monopoles = "Monopoles ""%04d" % i #Scale objects (needs to be adjusted, case specific) bpy.data.objects[strings].scale = (0.017, 0.017, 0.017) bpy.data.objects[monopoles].scale = (0.017, 0.017, 0.017) #Link materials of cube and cone to strings and monopoles cube = bpy.data.objects['Cube'] cone = bpy.data.objects['Cone'] stringsObj = bpy.data.objects[strings] stringsObj.data.materials.append(cube.material_slots[0].material) monopolesObj = bpy.data.objects[monopoles] monopolesObj.data.materials.append(cone.material_slots[0].material) #Camera and lamp stuff that need to adjusted, can also be done before running the script bpy.data.objects["Lamp"].location = (4, 4, 6) bpy.data.objects["Camera"].location = (4, 4, 4) #Render bpy.context.scene.render.filepath = imagepath bpy.ops.render.render(write_still=True, use_viewport=True) #Remove monopoles and strings objs = bpy.data.objects objs.remove(objs[strings], True) #Works for 2.77 and higher... objs.remove(objs[monopoles], True)