AUTO CREATION OF MENU ITEMS FOR GIZMOS. (MENU.PY) v2.0


 
This location is for Registered Users Only.
Perhaps you need to login or register.
Contributor: www.luma-pictures.com
Just drag and drop gizmos into the right folder and they will show up in your Nuke menus. No longer will you have to create the menu items manually for each gizmo you want to install.
Requirements:
6.0, 6.1, 6.2 or later
08 Feb 2011
2335
Just drag and drop gizmos into the right folder and they will show up in your Nuke menus. No longer will you have to create the menu items manually for each gizmo you want to install.
-Written by Paul Molodowitch!  Thanks man! 
Note: The previous Luma menu.py should be overwritten with this new one.

In the previous version of this, Gizmos would not load in the command line version of Nuke.  The fix was to use init .py.   Thanks again Paul!

 

OS X and Linux Easy install instructions.

1. Copy the menu.py and init.py into your ".nuke" folder. If these files already exist, merge the contents of the two in a text editor.

2. Copy the directories within the Gizmos folder directly into your ".nuke" folder

3. Open Nuke

OR If you want to put the gizmos into a subdirectory

1. Copy the contents of the zip folder into your .nuke directory.  If init.py and menu.py files already exist, merge the contents of the two in a text editor.

 2. Open init.py and add a "CUSTOM_GIZMO_LOCATION" path. Replace "" with your login name.

r'/users//.nuke/Gizmos'

 3. Save file and open Nuke.

 

 


The zipped download of all our Nuke tools can be found here.  There are also more in-depth download instructions!


http://www.luma-pictures.com/tools/nuke/

Please feel free to email [email protected] with any questions, comments, bug reports, feature requests, etc.  

www.luma-pictures.com
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Please login in order to download these files.

Comments   

 
# Lewi Lewis 2011-01-13 17:47
Thanks for these, much appreciated.
 
 
# Lewis Saunders 2011-01-19 03:56
this is very neat :-)

just be aware that if you do this you still need to add the plugin paths to init.py as well, or they won't be picked up by nuke when it's run for a command line render. so scripts created in the GUI might have nodes which the render farm can't find!
 
 
# Ivar Rystad 2011-02-14 02:37
This works great! Thanks alot!
But what is the easiest way to use this and get custom icons on the folders?
 
 
# Justin Johnson 2011-02-15 22:19
We are working on an update to this. We will try to include support for Icons soon. :-)
 
 
# Ivar Rystad 2011-05-23 03:04
Any news on an update to this? Would be awesome-o if it supported custom icons on the folders :-)
 
 
# Richard Blank 2012-03-21 01:15
Is there any way to make the CUSTOM_GIZMO_LO CATION path cross platform to work on both windows and Mac?
 
 
# Eli Intriligator 2012-05-17 00:58
I accidentally replaced the files and now it doesn't work. Is there something I can change in the python files so that they are default? (Please answer soon, I can't use Nuke until it is fixed.)
 
 
# Justin Johnson 2012-05-17 08:58
I am not sure what your issue is exactly.. You can email [email protected] and we can try to figure out what is going on.
 
 
# J Bills 2012-06-15 18:06
mega-handy. thanks for sharing.
 
 
# Cameron Carson 2012-09-18 12:27
Not sure if Anyone is interested but It's super easy to get Icons working provided you name them the same as the name of the gizmo. For example MyAwesomeGizmo. png goes with MyAwesomeGizmo.py.

All you have to do is change the line in the init.py under "recursiveAddGi zmoMenuItems()" that looks like this...

toolbar.addCommand(niceName,"nuke.createNode('%s')" % name)

to ...

toolbar.addCommand(niceName,"nuke.createNode('%s')" % name, icon=name+".png ")
 
 
# Cameron Carson 2012-09-18 12:28
Oh also Richard Not sure if anyone answered your question but the way you make the locations cross platform is to use something like this...

if sys.platform.startswith('win32'):
CUSTOM_GIZMO_LOCATION = r'PCLOCATION/AwesomeFolder/Gizmos';

if sys.platform.startswith('darwin'):
CUSTOM_GIZMO_LOCATION = r'MACLOCATION/A wesomeFolder/Gi zmos';
 
 
# Cameron Carson 2012-09-18 12:32
Oh I forgot to add that you have to have wherever you place your icons for this has to be added to the system path Using a line like this in the init.py. You might already have one. I did that's why I forgot.

nuke.pluginAddPath(".../gizmos/icons", addToSysPath=Fa lse);
 
 
+1 # Piotr Borowski 2013-05-17 05:58
Hi, I rewrote a piece of code:

def addGizmoMenuIte ms(self, toolbar=None, defaultTopMenu= None):
'''Recursively create menu items for gizmos found on the searchPaths.

Only call this if you're in nuke GUI mode! (ie, from inside menu.py)

toolbar - the toolbar to which to add the menus; defaults to 'Nodes'
defaultTopMenu - if you do not wish to create new 'top level' menu items,
then top-level directories for which there is not already a top-level
menu will be added to this menu instead (which must already exist)
'''
if not self._crawlData :
self.addGizmoPa ths()

if toolbar is None:
toolbar = nuke.menu("Node s")
elif isinstance(tool bar, basestring):
toolbar = nuke.menu(toolb ar)
self._recursive AddGizmoMenuIte ms(toolbar, self._crawlData , CUSTOM_GIZMO_LO CATION,
defaultSubMenu= defaultTopMenu,
topLevel=True)

def _recursiveAddGi zmoMenuItems(se lf, toolbar, crawlData, currentDir,
defaultSubMenu= None, topLevel=False) :
for name in crawlData.get(' gizmos', ()):
niceName = name
if niceName.find(' _v')==len(name) - 4:
niceName = name[:-4]
toolbar.addComm and(niceName,"n uke.createNode( '%s')" % name, icon=name+".png ")

for folder, data in crawlData.get(' dirs', {}).iteritems() :
import sys
subMenu = toolbar.findIte m(folder)
if subMenu is None:
if defaultSubMenu:
subMenu = toolbar.findIte m(defaultSubMen u)
else:
if topLevel:
subMenu = toolbar.addMenu (folder, icon= CUSTOM_GIZMO_LO CATION + r'' + folder + '.png')
else:
subMenu = toolbar.addMenu (folder, icon= currentDir + '' + folder + '.png')
self._recursive AddGizmoMenuIte ms(subMenu, data, currentDir + '' + subMenu.name())

Now all toplevel folders, subfolders and gizmos should be displayed with icons. You only need to create the icons and name it the same as the name of directories and gizmos and place them accordingly in the directory structure.
 
 
# KARTHICK K 2019-02-06 17:34
When i used this , throwing error line
import sys

for folder, data in crawlData.get(' dirs', {}).iteritems() :
import sys
subMenu = toolbar.findIte m(folder)

can you plesae correct it
 
 
# Doctor Remulak 2016-07-30 13:02
Awesome script. Thanx!
 

You have no rights to post comments

We have 3931 guests and 113 members online