4
$\begingroup$

Do you know any way to copy the exact attribute color values from the selected vertex to the clipboard? I ask because I would like to use vertex painting as id masks to create textures based on only one material. For this purpose i also created a simple node group that compares 2 colors and returns "1" if they are the same and "0" if they differ. The problem arises when I want to pick color of vertices of a specific part of mesh from the 3d viewport using a pipette - because "Filmic" changes colors, and I have to constantly switch to "Standard" mode to get a color sample for the id mask. The ability to directly copy the rgb or hex values to the clipboard from the selected vertex would probably be the best solution. Thx

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ "I have to constantly switch to "Standard" mode" I recommend saving it to your startup file. First thing I do when I download a new Blender version. $\endgroup$
    – scurest
    Jan 30, 2023 at 17:13

2 Answers 2

3
$\begingroup$

This isn't exactly an answer but you might find it useful. You can read the color value from the spreadsheet. Open the Spreadsheet Editor and turn on "Show Only Selected" in the upper right corner. Only rows for the currently selected verts will be shown.

Spreadsheet editor with Show Only Selected highlighted

Note that

  • You can only see 3 digits of the color value, which means it isn't exact.
  • The RGB values are displayed in linear space, not sRGB.
  • For vertex-domain colors, look under the "Vertex" tab. For corner-domain look under the "Face Corner" tab. All the corners attached to the selected vert will be shown. You can also select a face to see all the corners in that face.
  • You can see multiple color attributes if you have them (and other stuff like UV maps too).
$\endgroup$
2
$\begingroup$

This will fetch the color value from the color attribute corresponding to the select vertex. Be mindful that it won't likely work in your case because your vertex colors are stored in the faces corners, so a vertex can have any number of colors associated with it.

import bpy
import bmesh
import platform
import subprocess

obj = bpy.context.active_object
bm = bmesh.from_edit_mesh(obj.data)


def copy2clip(txt):
    cmd = "echo " + txt.strip()
    if platform.system() == "Linux":
        cmd += "|xclip"
    elif platform.system() == "Darwin":
        cmd += "|pbcopy"
    else:
        cmd += "|clip"
    return subprocess.check_call(cmd, shell=True)


for v in bm.verts:
    if v.select:
        idx = v.index
        bpy.ops.object.editmode_toggle()

        attribute = obj.data.attributes["Col"]  # Name of your vertex color attribute, case-sensitive
        attribute_value = attribute.data[idx].color
        print([c for c in attribute_value])
        copy2clip(str([c for c in attribute_value]))
        bpy.ops.object.editmode_toggle()
        break

Copy to clipboard adapted from this answer

$\endgroup$
1
  • $\begingroup$ Thank you for your answer and explanation. Indeed, it looks like a more complex issue than I thought, because in addition to what you wrote, there may be color attributes with other names, which is also a problem. So it seems that in this case it will be inevitable to change the color management to "standard" $\endgroup$
    – Zyzio
    Jan 30, 2023 at 17:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .