Howdy,
I have had some success adding gizmos from an arbitrary path, but it only
works for the nuke session.
I set this up by using nuke.pluginAppendPath(), and then creating a menu
item with nuke.createNode("gizmoName"). I have added this to
nuke.addOnScriptLoad(), but it gets executed too late and the custom nodes
will throw "ERROR: ... unknown command".
If I hardcode the path additions into the init.py, all of my custom gizmo
nodes work, but I would really like to have this functionality be dynamic
and based on the file that has been loaded.
Here is a functionally example of what I am trying to do. This will walk a
directory tree with gizmos, and build a matching menu tree.
# Load gizmos from a specified path to a specific menu prefix.
# menu can be set any arbitrary nuke menu or
# it can be set to false such that only the paths will be appended.
def loadProjectGizmos(rootPath,menuPrefix,menu=nuke.menu('Nuke')):
gizmoPaths=[]
for (path,dirs,files) in os.walk(rootPath):
for f in files:
if f[-6:] == '.gizmo':
gizmo = (os.path.join(path,f)).replace('\\','/')
gizmoPath = os.path.split(gizmo)[0]
if gizmoPath not in nuke.pluginPath():
nuke.pluginAppendPath(path)
gizmo = gizmo.replace(rootPath+'/',menuPrefix)
gizmo = gizmo[:-6]
if menu:
resultItem = menu.addCommand(gizmo,
'nuke.createNode("%s")' % (gizmo.split('/'))[-1], '')
#Usage example
loadProjectGizmos('/BasePath/to/Gizmos','HelloWorld/')
Cheers,
jesse
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python