Using init.py to dynamically change a plugin path based on the version of Nuke that is launched

Written by J. John Corbett on .

We purchased a plugin for our Nuke pipeline but it was a different file for Nuke 8 and 9.  Unfortunately, the plugin was named the same for both versions meaning we couldn't just drop two different files in the plugins folder and have it sort out automatically.  Using the environment variable, NUKE_VERSION_STRING, I was able to have Nuke check the version on loading and tell it to go to different folders for the plugin so it always finds the correct one.

In the main Nuke_Plugins folder (where we keep all our gizmos, python scripts, menu.py and init.py), I made two folders.  Let's call our new plugin, NewPlugin:

...Nuke_Plugins/NewPlugin8

...Nuke_Plugins/NewPlugin9

 

Then I added to the init.py: 


if
nuke.NUKE_VERSION_STRING == '9.0v5':

nuke.pluginAddPath("NewPlugin9")
else:
nuke.pluginAddPath("NewPlugin8")

  nuke.load("NewPlugin")

 

 

 

We have 2609 guests and 42 members online