3
$\begingroup$

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

$\endgroup$
2
  • $\begingroup$ link link link I see that there was once a lot of discussion regarding this topic. However according to those links it should habe been solved which surprises me. $\endgroup$
    – Erdorano
    Commented Mar 20 at 6:54
  • $\begingroup$ The workaround that fixed it for me, was to split it up into two segments so I'm first creating the color_attributes for every objekt and the baking starts once every object has its color attribute. $\endgroup$
    – Erdorano
    Commented Mar 20 at 8:29

0

You must log in to answer this question.

Browse other questions tagged .