Help make script work on all selected obj instead of just one Below is the code that is for flipping the vertex on an object. I want it so I can select all objects and run the script it does it to all the objects selected instead of doing them individually. If someone could edit it or tell me how to fix it that would be greatly appreciated.

import bpy

obj = bpy.context.active_object

for ipoly in range(len(obj.data.polygons)):
    for idx, ivertex in enumerate(obj.data.polygons[ipoly].loop_indices):
        ivert = obj.data.polygons[ipoly].vertices[idx]
        col = obj.data.vertex_colors.active.data[ivertex].color
        obj.data.vertex_colors.active.data[ivertex].color = tuple(1-x for x in col)
You can get all selected objects in:

objs = bpy.context.selected_objects


then just make a loop:

for obj in objs:


and then your code.

Done:

import bpy

objs = bpy.context.selected_objects
for obj in objs:
    for ipoly in range(len(obj.data.polygons)):
        for idx, ivertex in enumerate(obj.data.polygons[ipoly].loop_indices):
            ivert = obj.data.polygons[ipoly].vertices[idx]
            col = obj.data.vertex_colors.active.data[ivertex].color
            obj.data.vertex_colors.active.data[ivertex].color = tuple(1-x for x in col)