0
$\begingroup$

Follow on from this question but using v2.91.

I want to apply smart UV unwrap on all objects but if I use the code suggested in the link, I get an error

Traceback (most recent call last):
  File "<blender_console>", line 4, in <module>
AttributeError: bpy_prop_collection: attribute "active" not found

This is the code I used, what would be the suggested way?

import bpy
'''
objects = bpy.context.scene.objects
for obj in objects:
    obj.select
'''
if bpy.context.selected_objects != []:
    for obj in bpy.context.selected_objects: #loop through all the selected objects
        if obj.type == 'MESH':
            bpy.context.scene.objects.active = obj
            bpy.ops.object.editmode_toggle() #entering edit mode
            bpy.ops.mesh.select_all(action='SELECT') #select all objects elements
            bpy.ops.uv.smart_project() #the actual unwrapping operation
            bpy.ops.object.editmode_toggle() #exiting edit mode

I also tried to select all objects using obj.select but it doesn't recognise select.

$\endgroup$
2

0

You must log in to answer this question.

Browse other questions tagged .