I have two Cryptomatte layers, cmNode and cmNodeHierarchy.
When i select cmNode in Nuke all of cmNodeHierarchy channels are also selected, resulting in a pure_channels array looking like this:
['cmNode00', 'cmNode01', 'cmNode02', 'cmNodeHierarchy', 'cmNodeHierarchy00', 'cmNodeHierarchy01', 'cmNodeHierarchy02']
I propose a change to use regex or something similar. And in that case the whole _identify_channels function could be simplified.
New function:
def _identify_channels(self, name):
"""from a name like "cryptoObject",
gets sorted channels, such as cryptoObject00, cryptoObject01, cryptoObject02
"""
channel_list = []
if self.nuke_node.Class() in ["Cryptomatte", "Encryptomatte"]:
# nuke_node is a keyer gizmo or encryptomatte gizmo
channel_list = self.nuke_node.node('Input1').channels()
else:
# nuke_node might a read node
channel_list = self.nuke_node.channels()
channel_regex = re.compile(r'({}\d+)\.red'.format(name))
pure_channels = []
for channel in channel_list:
match = channel_regex.match(channel)
if match:
pure_channels.append(match.group(1))
return sorted(pure_channels)
Maybe other plugins than Nuke is affected by this as well.
I have two Cryptomatte layers, cmNode and cmNodeHierarchy. When i select cmNode in Nuke all of cmNodeHierarchy channels are also selected, resulting in a pure_channels array looking like this:
['cmNode00', 'cmNode01', 'cmNode02', 'cmNodeHierarchy', 'cmNodeHierarchy00', 'cmNodeHierarchy01', 'cmNodeHierarchy02']
This makes sense looking at the code https://github.com/Psyop/Cryptomatte/blob/e5ecd25de087c62bad8fd5c16399e8165bf0041a/nuke/cryptomatte_utilities.py#L231
I propose a change to use regex or something similar. And in that case the whole _identify_channels function could be simplified.
New function:
Maybe other plugins than Nuke is affected by this as well.