From: Greg Ercolano <erco@(email surpressed)>
Subject: Re: file paths for .mi files
   Date: Wed, 31 Jan 2007 18:14:35 -0500
Msg# 1468
View Complete Thread (7 articles) | All Threads
Last Next
(or if anybody knows a way to force maya to write them the way I want in the first place. I haven't been able to find any way to do that)

	This newsgroup item from last summer might help you:
	http://seriss.com/cgi-bin/rush/newsgroup-threaded.cgi?-view+1312

When I make .mi files on the mac using absolute paths for textures, etc they always end up starting wtih /Volumes/foo. I've gotten used to using BBedit to batch replace /Volumes/ with //corefileserver/ so that the pc's can render the files, but is there any way in rush to say

for this .mi file, use //corefileserver/ instead of /Volumes/ wherever it appears?

	Yes, you can do all that in perl, if the above newsgroup article
	on the 'dirmap' MEL command doesn't help you.

	In fact, the current submit-mray.pl script does a search/replace
	on the entire MI file to jam the output directory into
	incremental mi files, because ray's stinky -file_name flag
	only applies the change to the first frame in the incremental mi file,
	and doesn't apply to the rest of the frames.

	So the submit script makes a copy of the MI file in the rush tmp directory
	($ENV{RUSH_TMPDIR}) applying a regex replace to all lines in the file
	as it creates the copy.

	See the ModifyMIOutputDir() function in submit-mray.pl.

	You can just make a copy of that function, and just change
	the function name, and the bit of code inside the while() loop
	to apply the regex you need.

	Here's how I'd do it:

---- snip
# CHANGE ALL INSTANCES OF /Volume/ -> //corefileserver/
#    $1 - src mi file
#    $2 - dst mi file
#
sub FixMIFile($$)
{
    my ($src,$dst) = @_;
    unless ( open(SRC_MI, "<$src") ) { print STDERR "--- FAILED: open $src for read: $!\n"; exit(1); }
    unless ( open(DST_MI, ">$dst") ) { print STDERR "--- FAILED: open $dst for write: $!\n"; exit(1); }

    # BIN MODE (FOR WINDOWS)
    binmode(SRC_MI);
    binmode(DST_MI);

    while (<SRC_MI>)
    {
        s%/Volumes/%//corefileserver/%g;	# /Volumes/foo -> //corefileserver/foo..
        print DST_MI $_;
    }
    unless(close(SRC_MI)) { print STDERR "--- FAILED: close($src): $!\n"; exit(1); }
    unless(close(DST_MI)) { print STDERR "--- FAILED: close($dst): $!\n"; exit(1); }
}
---- snip

	This makes a big assumption that all instances of the word
	'/Volumes/' can be globally replaced with '//coreserver/' to make
	things work. (This might be bad if one of the user's pathnames has
	a subdirectory somewhere in the middle of the pathname called '/Volumes',
	but hopefully you can avoid that)

	So in the code, instead of rendering the original MI file with eg:

system("ray $miflags $mifile");

	..you might change that to read:

# FIX MI FILE FIRST, MAKING LOCAL COPY, *THEN* RENDER THE COPY
FixMIFile($mifile, "$ENV{RUSH_TMPDIR}/foo.mi");
system("ray $miflags $ENV{RUSH_TMPDIR}/foo.mi");

	..don't worry about removing the copy, rush will do that for you
	automatically when the frame finishes, as rush blows the entire
	$ENV{RUSH_TMPDIR} when the frame finishes or is dumped/requeued.


--
Greg Ercolano, erco@(email surpressed)
Rush Render Queue, http://seriss.com/rush/
Tel: (Tel# suppressed)
Fax: (Tel# suppressed)
Cel: (Tel# suppressed)

Last Next