From: Greg Ercolano <erco@(email surpressed)>
Subject: Re: Nuke Submit...
   Date: Wed, 10 Nov 2010 15:31:25 -0500
Msg# 1972
View Complete Thread (7 articles) | All Threads
Last Next
Craig Allison wrote:
> [posted to rush.general]
> 
> Has anyone done a Nuke submit script that auto pulls in all the basic =
> requirements for rendering from the current open script (i.e. Script =
> path, frames etc.)?
> 
> Looking to get our current submit a little more elegant so any tips =
> gratefully received!

Hi Craig,

	If no one else chimes in, I'll see if I can make one of these for ya.

	If you have a semi-recent version of rush, note that all the submit
	scripts take optional '-field' arguments, which allows you to pre-load
	the submit forms with data from the command line, eg:

		perl //somewhere/rushscripts/submit-maya.pl \
			-field "JobTitle:" "MY_TEST" \
			-field "Frames:" "2-222"

	..which will open the submit-maya form with the "Job Title" field
	preset to "MY_TEST", and the "Frames:" field set to "2-222".

	This is handy for opening up the submit form from inside nuke
	with e.g. the nuke scene file and frame range preset to what's
	currently loaded in nuke.

	Many folks have privately sent me code snippets on how to add
	Rush submit forms to nuke over the years, but some might be dated.

	I prefer to teach people to fish instead of giving them one ;)
	(I'll give you the fish in a separate followup to this thread)

SOME NOTES ON HOW TO ADD MENU ITEMS TO NUKE
-------------------------------------------

	Anyone wanting to create custom nuke menus should check this video:
	http://www.thefoundry.co.uk/articles/2009/12/01/77/nuke-python-essentials-adding-menu-items/

	Apologies if that link eventually goes stale. That video is also
	on "The Foundry Channel" on YouTube as: http://www.youtube.com/v/3-gR3ZpWTdw

TLDR; HOW TO MAKE A MENU ITEM IN NUKE
-------------------------------------
	For our purposes, long story short, the following code will create
	a submenu called "Rush" with an item called "Hello" which, when clicked,
	will open a "hello world!" dialog.. a good starting point.

		nukebar = nuke.menu("Nuke")
		rushsubmenu = nukebar.addMenu("Rush")
		rushsubmenu.addCommand('Hello', 'nuke.message("hello world!")')

	When you run that in the Nuke script editor, a "Rush" menu will appear
	in nuke's menubar.

A SLIGHTLY MORE USEFUL EXAMPLE
------------------------------
	The above commands show how to open a simple dialog, but what if we
	want to run our own python function that has more complexity?

	The second argument of the above addCommand() is a python command,
        so you can invoke the name of your own python function instead.

	So instead of calling 'nuke.message()', we can define our own function, 
        RushHello(), and set it up to be run when the item is clicked, e.g.:

		# DEFINE A FUNCTION CALLED "RushHello()"
		def RushHello():
		    nuke.message("hello world!")

		# MAKE A MENU ITEM THAT CALLS THAT FUNCTION
		nukebar = nuke.menu("Nuke")
		rushsubmenu = nukebar.addMenu("Rush")
		rushsubmenu.addCommand('Hello', 'RushHello()')

	Functionally this is equivalent to the previous example, but here we
	can go crazy with the contents of the RushHello() python function,
	adding code to do lots more stuff than just show a dialog.

	I'll follow up later with how to make nuke fire up the Rush
	submit form with data fields preset to the Frames and Nuke Script.

HOW TO MAKE THIS "PERMANENT" IN NUKE
------------------------------------

	You can add these commands to the global menu.py in the nuke 
        "plugins" directory, so whenever you run nuke the "Rush" menu
        will be there automatically, eg:

		  LINUX: /usr/local/Nuke6.1v1-32/plugins/menu.py
		WINDOWS: c:/program files/nuke6.1v1/plugins/menu.py

	For more info, see nuke's own docs on customizing nuke for other ways
	to approach defining your own plugins.

STEP BY STEP DETAILS ON HOW TO DO THE ABOVE
-------------------------------------------

	Here's some precise instructions for how to do the above tests
        for those not familiar with scripting in nuke. In the following case
        I'm using Nuke 6.1:

		1) Run 'nuke'

		2) Right-click on the 'Viewer1' tab, and choose "Script Editor"

		3) In the script editor window, you can type python commands.
		   Just as a test, try typing:

			nuke.message("hello world!")

		   ..and hit CTRL-ENTER to run it. A dialog should pop up
		   saying 'hello world!' and you can click OK to close it.

		   Note: Similar to Maya's script editor, hitting just 'ENTER'
		   gives you a new line without running the command. This way
		   you can compose large multiline code snippets. When you want
		   to run everything you've typed, hit CTRL-ENTER.

		4) Now you should be able to paste the above commands to create
		   a "Rush" menu with the "Hello" submenu item, eg:

		        nukebar = nuke.menu("Nuke")
		        rushsubmenu = nukebar.addMenu("Rush")
		        rushsubmenu.addCommand('Hello', 'nuke.message("hello world!")')

                   Be sure to hit CTRL-ENTER after pasting to run it.

[EDITED FOR CLARITY - erco 11/10/10]
-- 
Greg Ercolano, erco@(email surpressed)
Seriss Corporation
Rush Render Queue, http://seriss.com/rush/
Tel: (Tel# suppressed)ext.23
Fax: (Tel# suppressed)
Cel: (Tel# suppressed)

Last Next