The problem: I am working with a set of objects in Blender with per-vertex colours. Each object has only two distinct colours. For all objects in a selection, I am choosing only the brighter of those two colours, and increasing its brightness by 10%.
Language: Python 3.7
About me: I am new to coding in Python, having read through a few tutorials and looked at some example code that other Blender users have created. I have coded extensively in R, but am completely self-taught, so who knows what bad habits I have picked up.
Feedback requested: any, but in particular if there are any big efficiency gains that I can make, given that I am working with meshes that have large numbers of vertices.
from bpy import context # Iterate over all selected objects selection = context.selected_objects for object in selection: # Get the colour data for the selected object v_col = object.data.vertex_colors color = list(v_col.data.color) # Find the colour of the brighter segment all_colours = list() for data in v_col.data: all_colours.append(list(data.color)) segY = max(all_colours) # Assign new colour values to this segment new_colour = [min(x*1.1, 1) for x in segY] for data in v_col.data: if list(data.color) == segY: data.color = new_colour