Using mesh.addColorLayer in Python

First let me describe the non-Python problem that the script I am writing is meant to automate.

I have a complex model with 50-60 objects. I am exporting the object using a python script which is working beautifully. The coloring of the model uses a simple vertex coloring (a simple colored material assigned to the object/mesh) and a manually added vertex color layer. This is effectively ‘baked in color’ as I don’t light the model where it is finally rendered.

However, if I change the color of any object, I have to delete it’s vertex color layer and add a new one for the effect to take.

If I change the lighting I have to do this for all the objects in the model for the lighting changes to take effect.

So firstly, am I overlooking a global ‘recalculate vertex color layers’ function here that would save me writing a script?

In the script, I essentially perform on each mesh:


mesh.activeColorLayer = ‘Col’

Which appears to do exactly what I am doing manually in Blender’s UI, but the effect is to leave an uncolored model, even though rendering in the 3d view and in the render window is correct.

Any thoughts?