select face by vertex color

can anyone help me find a way to select the face of an object by vertex color

Welcome to BA :slight_smile:
While not possible in vanilla Blender, there are some workarounds. For example, this script:

Or this, updated, script:

Thereā€™s also this add-on:

And this add-on:

Of the two add-ons, the second one will probably work better, as the first one seems to be having some kind of error, and the second one is a 2.8+ specific fork.

thanks Joseph for such a good welcome in the community!!!
Iā€™m trying to select polygons with a specific color!! I want to note that object is imported from quill.and therefore I want to give different shaders to different parts!

i tried your script and nothing happens :((( maybe iā€™m doing something wrong

image

P.S.
this add-on is not active for purchase

1 Like

Thatā€™s unfortunate :thinking: I havenā€™t actually personally used that script, I will download it and give it a shot, see if I can figure it out.

1 Like

this ball is an example! Letā€™s say I want to delete green objects!

ball_color.blend (3.0 MB)

maybe I can get the vertex color using the geometry nodes? @joseph

1 Like

Iā€™m sure you can try :slight_smile:

trying to find it! but no results :frowning:

In case anyone else stumbles across this thread :slight_smile:
In 3.6.3 at least, in Geometry Nodes

Add-> Geometry-> Read-> Named Attribute

allows access to ā€˜Colā€™ or any piece of data in your modelā€™s spreadsheet.

3 Likes

Two years later, none of these links work or produce a result in Blender 4.0ā€¦ :face_with_diagonal_mouth:

I donā€™t think geo nodes solutions work for me, because I just need a selection.

You can totally use a GN tool for that:


Good luck.

3 Likes

Ah right, the new toolsā€¦ ok, but regardless if I input ā€œColā€ as suggested above or ā€œAttributeā€ as some other places I found suggest, the following setup always selects everything:

Anyone know what I am doing wrong?

Also, sharing this involves a number of extra steps (and even requires an add-on like this just to save the node only to a new file, right?)ā€¦ but attempting to modify those python scripts are even more difficultā€¦ I tried looking up bmesh but itā€™s above my head so far.

Go read this.

You canā€™t use Attribute statistics in this case as it outputs a constant and you need fields.

Whatā€™s wrong with my suggestion?

I didnā€™t notice that Attribute Statistic didnā€™t have field outputs (since it has field inputs)ā€¦ and Capture Attribute doesnā€™t seem to have the inputs required.

Your suggestion doesnā€™t grab the target color from the selection, I think? Besides, I donā€™t like the convoluted process of sharing and re-using geometry nodes. Maybe if they could be saved in the equivalent of a .gn file (like with .py).

But Iā€™m not doing too well in Python eitherā€¦ loops.layers.color.items in Bmesh/BMFace seems to have 0 length even though I have baked down a color attribute on my mesh and I can see it in both the details panel and the viewport.

I was doing some code hacking with python a few months ago involving vertex color assignment; Iā€™ll see if I can backtrack my findings on that and see if selection was something Iā€™d worked out.

(I definitely would want to avoid resorting to geonodes for such a thing.)

ETA - you might find this useful.

1 Like

Ok, finally managed to make thisā€¦

Some notes for anyone who finds this in the future:

  • Blender can record vertex color in two different ways (which is what made finding examples of code that worked so difficult). Iā€™ve only tested the first way here since thatā€™s what I had, so the other branch of the code might not work.
  • You wonā€™t actually see your selection, because update_edit_mesh throws an error for some reason, and none of the other ways of updating that I found seems to work, but the selection is getting made.
  • The code might be slow because Iā€™m looping through everything twice. I couldnā€™t figure out the numpy selection optimizations people were doing, and not having an easy way to get the selected things seem to be a long standing issue.
2 Likes

Funny that you mention that thread, as it was also one that I was going through this summer trying to determine a pathway to getting some code to work.

Iā€™m normally not one to invoke the term ā€œman-splainingā€, but that thread was a perfect example of it unfortunately.