I need a script, that batch processes the selected objects, creates a color_attribute slot and bakes the AO onto this slot. This works fine with individual objects. However when I try to boundle it into a batch process, the script returns an error.
import bpy
for obj in bpy.context.selected_objects:
obj.data.color_attributes.new('AO', 'BYTE_COLOR', 'CORNER')
bpy.ops.object.bake(type='AO', target='VERTEX_COLORS')
Error:
RuntimeError: Error: Mesh does not have an active color attribute "Object name"
Has someone an idea, how to solve this? I'm at Blender Version 4.0.1