Q100491: How to automatically localize files from multiple paths

Follow

SUMMARY

This article outlines how you can automatically localize files from multiple different paths, as currently, Nuke’s 'auto-localize from' feature only allows localization from one path by default.

 

MORE INFORMATION

Nuke

You can automatically localize files from multiple locations in Nuke by writing a Python script, which you then add to your init.py file. The example code below will localize files that are stored within either of the following file paths: /first/localization/path/ or /second/localization/path/

import nuke

localizationDrives = ('/first/localization/path/', '/second/localization/path/') #add paths you want to localise from to this tuple

def automaticLocalization(*localizeFrom):
if nuke.thisNode()['file'].value().startswith(localizeFrom):
nuke.thisNode()['localizationPolicy'].setValue('on')

nuke.addOnCreate(automaticLocalization, args=(localizationDrives), nodeClass="Read")

The code works by first creating a tuple of directories to localize from. Then the function, called automaticLocalization, is defined. Inside this function, the code checks whether the current Read node's file knob has a value that starts with either /first/localization/path/ or /second/localization/path/

If this criteria is met, the Localization Policy for that node is set to ‘on’. The addOnCreate callback is then used to call the ‘automaticLocalization’ function whenever a Read node is created in the Node Graph. 

 

Hiero

The exact same code as above can also be used to localize files in the Hiero timeline. However, for it to be executed on startup, this code would need to be added to your ~/.nuke/Python/Startup directory instead.

 

Nuke Studio

From our testing, it appears that adding the code to either your ~/.nuke/Python/Startup directory or your init.py file will work for both the timeline and Node Graph, so you should incorporate this into your setup to best suit your current pipeline and workflow.

 

FURTHER READING

There is currently a feature request logged for allowing the 'auto-localize from' feature to accept multiple paths. The reference number for this is the following:

TP 147811 - Add the ability to Auto Localise from multiple locations, not just one

You can reference this number in the release notes of upcoming versions of Nuke to see if it has been addressed.

    We're sorry to hear that

    Please tell us why