Import baked attribute map as vertex colors? (Maya Python API)

I’m currently writing a tool for Maya 2022 which is intended to bake ambient occlusion data into vertices. So far, I have a managed to automate the process of creating a new packed UV Set, generating ambient occlusion data as a .EXR file, and assigning an empty vertex color set.

However, to complete the pipeline, I need to bake the .EXR file into the aforementioned vertex color set, using attribute maps. I’ve managed this manually (via Paint Vertex Color Tool > Attribute Maps > Import), but despite a thorough search of Maya’s Python API documentation and the internet, cannot figure out how to do this in Python. I’m aware of cmds.artAttrPaintVertexCtx, but unfortunately can’t quite work out how to relate it directly to what I need to do.

If anyone has any insight into what I should be doing, I’d really appreciate it!

(For reference, when my current code ends, I have a variable for the generated EXR file path, the current selection consists only of the main object, and the current context is “moveSuperContext.”)

Hey there

I’d say:

  • get each vertex UV position (where is my vertex on the texture)
  • sample the texture for each vertex ( How to Sample a 3D Texture in Maya )
  • If a vertex is split on UV (part of a seam), average the color values for this vertex
  • Apply those colors to each vertex.