// =========================================================================== // 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. // =========================================================================== global proc launchImageViewer( int $sequence ) //Description // This procedure invokes the application to view an image or a sequence // $fileName is the absolute path to an image // $sequence = 0 is an image // $sequence = 1 is a sequence { //construct the name of optionVar, that is to record the last path you chose. string $optionVarName = "browserLocation"; if($sequence) { $optionVarName += "ForSequence"; } else { $optionVarName += "ForImage"; } //check the stored optionVar for the path to look in first for the image file if (!`optionVar -exists $optionVarName`){ //if the optionVar does not exist, we should treat "images" file rule as the start directory string $fileRuleValue = `workspace -q -fre images`; string $fileRulePath = `workspace -expandName $fileRuleValue`; //get directory of "images" file rule $fileRulePath += "/*.*"; optionVar -stringValue $optionVarName $fileRulePath; } //query the optionVar string $filePath = `optionVar -query $optionVarName`; //let the user specify the image or sequence to view string $fileName = `fileDialog -directoryMask $filePath`; if ($fileName != ""){ launchImageApp($fileName, $sequence, 0); //change the optionVar to the latest image so we look in the //right place next time int $numPathComponents;//number of pieces to the file path string $filePathBuffer[];//break the file path into pieces $numPathComponents = `tokenize $fileName "/" $filePathBuffer`; string $newFilePath; //reassemble the path to the selected file without the fileName int $i; if (`substring $fileName 1 1` == "/") $newFilePath += "/"; for ($i = 0; $i < ($numPathComponents - 1); $i++){ $newFilePath += $filePathBuffer[$i]; $newFilePath += "/"; } //finish the path with a wildcard $newFilePath += "*.*"; //set the optionVar optionVar -stringValue $optionVarName $newFilePath; } }