Save copy of scene in relative location

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  10 October 2012
Save copy of scene in relative location

Using mel, how would I save a copy of a scene file in a relative location such as Project01/maya/renderScenes and later if I was working on another project (and Maya was set to that project) have the script save a copy of the scene file to Project02/maya/renderScenes

I'm assuming it's a combination of
string $currentSceneFilePath = `file -q -sceneName`;
to get the scene name

along with
file -f -save -type "mayaBinary";
(but how to check if it's a .ma or .mb?)

and some way to get the project directory then adding on "renderScenes"?

I'm very new to scripting so any examples would be very helpful.
  10 October 2012
Not sure how Mel does it but with Python it's only a 1 line command. So I guess you could do it this way.

string $currentScene;
string $currentPath;
string $pyCommand;

$currentScene = `file -q -sceneName`;
$pyCommand = "os.path.dirname(\"" + $currentScene + "\")";

python( "import os");
$currentPath = python( $pyCommand );

Here my $currentScene = P:/CGworkshop/project/scenes/
Result of $currentPath = P:/CGworkshop/project/scenes
  10 October 2012
Thanks. Since Deadline's submission script is in mel I was hoping to attach it to the CustomSanityChecks.mel file so that a copy of the scene file gets stored in the project's directory (for future archiving). Can you call up a .py file from a .mel file or is it just better to just keep it all together in mel?

Also Deadline is able to swap the slashes for cross platform support (PC/Mac), wasn't sure if that needed to be written in as well or if it's simply handled in the main submission script.
  10 October 2012
Hmmm I'm pretty sure the Mel script is executed within Maya. But this might be safer.

$full = `file -q -sceneName`;
$short = `file -q -sceneName -shortName`;

$test = `substitute $short $full ""`;

$full --> P:/CGworkshop/project/scenes/
$short -->
So the substitute command is basically replace with an empty string.

You can use this if you want to be sure about slash/back-slash

$test = toNativePath( $test )

Last edited by Panupat : 10 October 2012 at 04:56 PM.
  10 October 2012
I feel like I'm close but still don't know how to specify the relative path of $renderScenesFolder for the directory /maya/renderScenes folder. Any ideas?

$sceneName = `file -q -sceneName`;
$currentSceneDir = `workspace -q -dir`;
$currentDir = `workspace -q -rd`;

\\ How to set this from the $currentDir or $currentSceneDir ??
$renderScenesFolder = ???

string $source = $sceneName;
string $destination = $renderScenesFolder;

sysFile -copy $destination $source;
  10 October 2012
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 10:43 PM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.