From: Greg Ercolano <erco@(email surpressed)>
Subject: [Q+A] Middle-click in irush -- is there a way to change the image
   Date: Tue, 30 Apr 2013 12:24:15 -0400
Msg# 2327
View Complete Thread (1 article) | All Threads
Last Next
> We use (RV, NUKE, DJV, etc), and would like to have it so when
> artists middle-click in irush, it uses that instead of (fcheck, Preview, etc)

	Yes, the middle-click feature in IRUSH is completely customizable.

	IRUSH has always had this feature since first releases in 2002 or so,
	but it's never been well documented how it works, so I'll go into some
	details below.

	In the case of submit-maya, long story short, middle-click in irush
	ends up calling the function MAIN_ImageCommand() in that script,
	and you can change that function to invoke rv or djv or whatever.

	So in submit-maya.pl, for instance, you could change the following
	line in the MAIN_ImageCommand() function:

DisplayImage($image, "fcheck");

	..to instead something like:

system("rv $image");

	Some submit scripts set this up differently, or don't set this
	up at all (in which case a middle-click in irush will do nothing).

	If you're writing a custom submit script, here's some info
	on how to get your script to take control of IRUSH's middle-click
	feature.

	First, some background.

	Since every job is different (Maya, Nuke, etc), each job
	usually wants its own way of handling image viewing during
	rendering, ie. what IRUSH middle-click will do.

	Nuke users usually want nuke to view the image, maya users
	usually want fcheck, or may want something better.

	Some jobs don't render images at all, some generate text output
	or model databases, and they want IRUSH middle-click to open
	either a text editor, or model viewer on the generated data.

	To allow this flexibility, rush lets the submit script define
	the command IRUSH will run when someone middle clicks a frame..
	this is done as part of the low level job submission.

	In the case of submit-maya, it sets itself up as the imgcommand,
	passing it an -imgcommand argument so that the script knows it's
	supposed to show an image:

rush -submit << EOF
...
imgcommand perl /path/to/submit-maya.pl -imgcommand %s
...         ------------------------------------------
EOF                           |
                              This is the command IRUSH will run
                              when someone middle clicks on a frame.
                              IRUSH replaces the %s with the frame# clicked on.

	'imgcommand' is one of the optional 'rush -submit' commands
	that irush will look for when someone middle-clicks a frame,
	and you can set this command to be whatever you want; a python or perl script,
	bash, ruby, or even an executable.

	If the job doesn't define an 'imgcommand' during the 'rush -submit',
	then IRUSH will do nothing on a middle-click.

	The jobid is passed to the command in the RUSH_JOBID environment variable,
	and the frame# the user clicked on is passed as an argument to the script
	(IRUSH will replace the '%s' with the frame# before invoking the command)

	IRUSH doesn't know where jobs write out their images, it just knows
	the job's jobid and frame# that the user clicked on. So when IRUSH
	runs the imgcommand, the command has to figure out where the images
	are located and show the right image.

	In the case of maya, the script ends up invoking 'rush -log <frame#>'
	to get the render output for that frame, and parses that output
	looking for a message from the renderer showing where the image
	was written, and then runs the image viewer to show it.

	If it can't determine where the image was written, it usually posts
	a dialog error indicating the log didn't have a message in it about
	where the image is being written.

	Sometimes at submit time, the path to the images is known in advance.
	In such a case, it helps to pass that pathname as part of the imgcommand
	so that it doesn't have to go "dumpster-diving" into the frame logs
	finding a message saying where the image was written.

	So for instance, if the path is known to be /some/where/images,
	and the basename for the images will be "foo.####.tif", then:

rush -submit << EOF
...
imgcommand perl /path/to/yoursubmit-xxx.pl -imgcommand /some/where/images/foo.%s.tif
...
EOF

	..would be a good way to do it.

	This way the script knows the path to the image right away,
	and IRUSH will automatically expand the %s to the frame# the
	user clicked on, usually a 4 digit padded frame#.

	In these cases, one could almost invoke the image viewer directly, eg:

imgcommand djv /known/path/to/images/basename.%s.tif

	..since IRUSH will replace the %s with the frame#.

	But usually it's better to have a script handle invoking the viewer
	to handle special input/output redirection, backgrounding the command
	so it doesn't hang up the irush interface, setting up any environment
	variables the image viewer might need, etc.

Last Next