uv smart projecting multiple objects via python loop issue i have 100 of objects in a scene, which i need to assign UV (smart project), so they don't rely in default cubical space of shader. i tried following code ( written in few minutes) upon running, it only work (as expected)on first or last object. just can't figure out why. only one object shows texture after running. ahh..

import bpy

meshObjs = []
for each in bpy.context.selected_objects:
    if each.type == 'MESH':
        meshObjs.append (each)

    # clear selection
    bpy.ops.object.select_all(action='DESELECT')
    # iterating mesh objects
for obj in meshObjs:
    d = obj.data
    #obj.select = True
    bpy.data.objects[obj.name].select = True
    bpy.ops.object.mode_set(mode = 'EDIT')
    bpy.ops.mesh.select_all(action='DESELECT')
    bpy.ops.mesh.select_all(action='TOGGLE')
    obj.update_from_editmode()
    print (obj.name) 
    bpy.ops.uv.smart_project()
    obj.update_from_editmode()
    bpy.ops.object.mode_set(mode = 'OBJECT')
    obj.select = False
You need to set the object as the active object. You can add bpy.data.scenes['Scene'].objects.active = obj at the beginning of your loop.