Is there a way to get Cryptomatte ID of the object?

I want to add a list of objects to bpy.context.window.scene.node_tree.nodes['Cryptomatte'].matte_id but I could not find a way to determine their crypto IDs. The CompositorNodeCryptomatte documentation only mentions manual way to pick crypto IDs. Is this possible to do with Python API?

There isn’t an API as Cryptomatte is currently a Cycles features and not part of Blenders’ core. There is a plan to add it to Blender core, but that is still in the planning stage. https://developer.blender.org/T81058

Blender follows the Cryptomatte standard for hashing names.
For hashes the name of the object, material or asset is hashed using util_murmur_hash3 and converted to a float using util_hash_to_float. see https://developer.blender.org/diffusion/B/browse/master/intern/cycles/util/util_murmurhash.cpp for implementation.

1 Like