I try to unwrap UVs to every object, but after running the script, the UVs of the previous object and the latter object are associated.
I tried to deselect UVs and objects,but Didn't solve the problem,Here is my code:
import bpy
Num = len(bpy.data.collections['AutoUV'].objects)
for i in range(Num):
bpy.ops.object.select_all(action='DESELECT')
bpy.data.collections['AutoUV'].objects[i].select_set(True)
bpy.ops.object.editmode_toggle()
bpy.ops.uv.select_all(action='SELECT')
bpy.ops.uv.smart_project()
bpy.ops.uv.select_all(action='DESELECT')
bpy.ops.object.editmode_toggle()
```
smart_project()operator works on the active object(s) in Edit Mode so you'd have to make each object the active one within the loop and call the operator, I have just updated Carlo's answer here: https://blender.stackexchange.com/a/103199/ Does this help? Also see: https://blender.stackexchange.com/questions/126577/blender-2-8-api-python-set-active-object – brockmann Nov 04 '21 at 09:15for obj in selection:bybpy.data.collections['Collection'].objects:. Cheers. – brockmann Nov 05 '21 at 07:23