Python panel to manage read nodes

Python panel to manage read nodes

This is me getting too lazy to deal with one read node at a time.

Currently this tool only includes two scripts:

  1. selectRead: Click, and it’ll select all your read nodes!
  2. setLocalization: A simple pop up for you to set localization policy, for read nodes only or everything (like readGeo2)

Note: ‘Convert file path to absolute’, ‘Select Nodes with File Knob’ and ‘Set Project Directory’ comes from another script called SetProjDir.

setLocalization expanded


As shown below ‘on demand’ is new from nuke11.1. If you select ‘on demand’ in previous versions it will simply becomes ‘off’.

Simple as that! I plan to add another pop up that changes ‘on_error’ knob, or perhaps merge it with the “Change localization” panel.

In the process of writing setLocalization I experimented with nukescripts.PythonPanel as I said I would in this post, which I explained a problem with using nuke.EnumerationPulldown while writing this function. I guess what’s unexpected is what really got me into looking into it is, the old nuke.panel doesn’t have a text knob.

I was surprised that nukescripts.PythonPanel was quite poorly documented, so I figured most of these on my own. Turned out I don’t necessarily needs to create a class or self as shown in nuke python developer guide if I just wanted a simple pop up panel.

p = nukescripts.PythonPanel('Change localization')

This will create a pop up panel.

p.checkboxKnob = nuke.Boolean_Knob('readOnly', 'Read nodes only', '1')
p.localizationKnob = nuke.Enumeration_Knob('localizationPol', 'Set localization policy', ['on', 'from auto-localize path', 'on demand', 'off'])
p.textKnob = nuke.Text_Knob('text', '', '"on demand" only available since nuke11.1')

All these to create the knobs that I want, needs to declare them as variables so that I can add

for k in (p.checkboxKnob, p.localizationKnob, p.textKnob): p.addKnob(k)

Adding knobs into the panel “p” as declared in first line.

if p.showModalDialog(): if p.localizationKnob.value() == 'on': c = 0

And to retrieve the values after the user press “Okay” when panel popped up.

I find it slightly more complicated than the simple nuke.Panel, but it is significantly easier to add knobs. Knob types available are here for future reference. Also to grab the values later the attribute value() seems more fitting in python, compare to something such as

p.value('file path')

in nuke.panel.

This tool is now available for download on nukepedia here. You will also find any future updates or development on that page.

One thought on “Python panel to manage read nodes

Leave a Reply

Your email address will not be published. Required fields are marked *