How to use Cryptomatte to render modifier objects with Array in different colors?

Is there a way to assign different colors to duplicated objects using the array modifier and render them with Cryptomatte?

Hello and welcome to the forum !

in short it’s very very tricky !
Cryptomatte allows to select by object or by material, but array modifiers duplicate geometry just like if you did it in edit mode.
So it’s considered only one object, and with the same material than the original.

If you render with Cycles you can use random per island :

Something like that should give each part of the mesh a different color.

If things get more complicated or you’re using eevee, your last hope is geometry node,
you can do the array there and store an attribute to separate each duplicate.

That’s about it, depending on the case, things might become even more complicated, if say , you want to assign specific colors to a specific object, compared to some random assignement.

And if your object is complex and made of a lot of parts it’s going to make things a bit harder…

But, maybe something a bit simpler might emerge from that brainstorming…
Good luck !