// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // Creation Date: November 12 2000 // // Procedure Name: // incrementalSaveProcessPath // // Description: // Returns the information that we'll need to do the incremental save, // based on the current scene file. // // Return Value: // String array where elements are as follows: // 0 - scene name // 1 - scene path // 2 - scene name extension // 3 - scene prefix // 4 - version string // 5 - increment dir name // global proc string[] incrementalSaveProcessPath() { string $result[]; // Separate the full filename into path and name (eg. "C:/maya/projects/scenes/" and "myScene.mb") // string $scenePath = `file -q -sceneName`; string $sceneName = `match "[^/]+$" $scenePath`; $scenePath = `substring $scenePath 1 (size($scenePath) - size($sceneName))`; string $sceneExtension = `match "[.][^.]*$" $sceneName`; if($sceneExtension == `match "[.][0-9]+" $sceneExtension`) { $sceneExtension = ""; } string $fullScenePrefix = `substring $sceneName 1 (size($sceneName) - size($sceneExtension))`; string $currVersionString = `match "[.][0-9]+$" $fullScenePrefix`; $currVersionString = `match "[0-9]+" $currVersionString`; // Find the extension and "prefix" of the sceneName. We may use the "fullScenePrefix" later. // For example, we would want "myScene4.screen2.0001.mb" to give us "myScene4.screen2" // string $sceneNamePrefix = $fullScenePrefix; if($currVersionString != "") { $sceneNamePrefix = `substring $sceneNamePrefix 1 (size($sceneNamePrefix) - size($currVersionString) - 1)`; } string $incrementDirName = "incrementalSave/" + $sceneNamePrefix + $sceneExtension + "/"; string $lastDirectoryName = `match "incrementalSave/[^/]+/$" $scenePath`; if($lastDirectoryName == $incrementDirName) { // The directory-name for storing older increments is already at the end of the // path for the current scene, so we can assume that the user is saving changes to // an older increment. We will want to save these changes to the original scene name. // $scenePath = `substring $scenePath 1 (size($scenePath) - size($lastDirectoryName))`; } else { // There is the possibility of users naming a scene so that it ends in // a number (myOriginalScene.4.ma), just like increments are. // If this happens, the previous code will have been fooled into thinking that // the number was not part of the scene name. However, if we know that we're // not inside the increments directory, then we know that the full original // scene prefix should be used (not the one with the number trimmed off!). // $sceneNamePrefix = $fullScenePrefix; $incrementDirName = "incrementalSave/" + $sceneNamePrefix + $sceneExtension; } $result[0] = $scenePath; $result[1] = $sceneName; $result[2] = $sceneExtension; $result[3] = $sceneNamePrefix; $result[4] = $currVersionString; $result[5] = $incrementDirName; return $result; }