Select by image mapped color?

OK, so I am working with a lego-style model and am trying to separate the light blue bricks from the dark blue bricks. There are a lot of bricks. The color is currently only from an image mapped to the grid of bricks, so I cannot use the “Select all using this material” thing as they all have the same material. My first guess is that this is not something that is possible, but I am open to any suggestions on how I could go about this in a more efficient manner than selecting each brick one by one.

You could use a few lines of python, or…

You could join all the blocks together, (Select all and J) and then tab into mode, and select by material.

I feel like I may not have explained myself very well… They all have the same material. its an image. And they are all already joined into the same object. I am trying to separate them by color to change their positioning.

Well, it kind of depends on your image. If all of your blue uvs are in say the lower right corner of uv space (or easily selectable somehow) you can synch up your uvs and verts, so that when you select the uvs, the verts also become selected in edit mode (in the uv editor there’s a toggle, icon is cube with 2 verts, tooltip is ‘keep uv and edit mode mesh in synch’) so you select the lower right half of the uvs, thus selecting the corresponding verts, and then separate (p ‘by loose parts’)

I don’t know if this is relevant …?

One crude option is to bake to vertex colors which are much easier to handle than trying to find where UV’s cover what color on an image.

  • add vertex color layers
  • bake textures to vertex colors. face textures if there’s no material assigned one
  • select one object, select similar with the script, do whatever
  • remove vertex color layers


For adding and removing color layers


# Add or remove vertex color layer to selected objects
# Parameter addlayers: True = Add, False = Remove

addlayers = True

import bpy

C = bpy.context

for o in C.selected_objects:
    if o.type == "MESH":
        C.scene.objects.active = o
        (bpy.ops.mesh.vertex_color_add() if addlayers else bpy.ops.mesh.vertex_color_remove())


For selecting


# Selects all mesh type objects based on similar vertex colors in the selected one.
# One color per object

tolerance = 0.05

import bpy
from mathutils import Color

C = bpy.context

col = C.object.data.vertex_colors[0].data[0].color
min = sum(col) - (3*tolerance)
max = sum(col) + (3*tolerance)

for o in C.scene.objects:
    if o != C.object and o.type == "MESH":
        col2 = sum(o.data.vertex_colors[0].data[0].color)
        if col2 >= min and col2 <= max:
            o.select = True