Home > Blockchain >  How to devide RGB mask by name in Nuke with python
How to devide RGB mask by name in Nuke with python

Time:12-22

I am making an autocomp solution for my projects in Nuke and I want to be able to rename my RGB masks with their intended name.

So say these are my three RGB mask shuffle nodes stored in a list:

['RGB_boxes_01_-Box_red-Box_green-Box_blue',  'RGB_boxes_02_-Box_red-Box_green-Box_blue', 
 'RGB_boxes_03_-Box_red-Box_green-Box_blue']

Thay each contain red green and blue channels that I want to split an rename "Box_red", "Box_green" and "Box_blue"

Now splitting the channels are easy, but renaming them to their intended name is harder. Anyone nows a good way to do this?

I thought it was a good idea to put "-" in front of every channel so that I can have a specific pattern when I am dividing, but so far I cant figure out how to do this.

Thanks!

CodePudding user response:

I don't have much experience with python & channels, however I know that nuke layers/channels are immutable and permanent in a script - once they're created, they can't be destroyed without possibly editing the script manually.

Check out this API page around layers, it should give you the syntax you need for your code: https://learn.foundry.com/nuke/developers/105/pythonreference/nuke.Layer-class.html

CodePudding user response:

Thanks!

But its not actually a question about channels in nuke, but more a about how do I split these strings in this list based on a pattern.

So how do I make this

['RGB_boxes_01_-Box_red-Box_green-Box_blue',  'RGB_boxes_02_-Box_red-Box_green-Box_blue', 
 'RGB_boxes_03_-Box_red-Box_green-Box_blue']

spit out this:

['Box_red', 'Box_green', 'Box_Blue']
['Box_red', 'Box_green', 'Box_Blue']
['Box_red', 'Box_green', 'Box_Blue']
  • Related