// =========================================================================== // 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: Jan 31, 2007 // // Procedure Name: // AEreplaceFilename // // Description: // This is part of a set of methods for changing // a property sheet to point to a new node. // (A way of efficiently re-using existing controls) // This method re-connects a filename control. // // Input Arguments: // The name of the existing control // The name of the new plug // // Return Value: // None // // // Procedure Name: // AEassignFilenameCB // global proc int AEassignFilenameCB( string $fileAttribute, string $filename, string $fileType ) { // // Description: // This procedure is called when the user changes the file texture name in // the edit box in the file texture attribute editor (whether by manually // typing it in, or by using the file browser to choose a new file). // // This procedure updates the file name attribute setAttr $fileAttribute -type "string" $filename; string $currentDir = `workspace -q -dir`; retainWorkingDirectory ($currentDir); return true; } // // Procedure Name: // AEfilenameBrowser // global proc AEfilenameBrowser( string $cmd ) { string $workspace = `workspace -q -fn`; string $startDir = `setWorkingDirectory $workspace "image" "sourceImages"`; string $filter = buildImageFileFilterList(); string $caption = (uiRes("m_AEreplaceFilename.kOpenImage")); string $fileCmd = ("fileDialog2 -caption \"" + $caption + "\" -fileMode 1"); $fileCmd += (" -fileFilter \"" + $filter + "\""); $fileCmd += (" -startingDirectory \"" + $startDir + "\""); string $file[] = `eval $fileCmd`; if (0 < size($file) && "" != $file[0]) { string $path = fromNativePath($file[0]); $cmd += (" \"" + $path + "\" \"\""); eval $cmd; } } // // Procedure Name: // AEreplaceFilename // global proc AEreplaceFilename( string $controlName, string $plugName, string $changedCommand ) { string $curParent = `setParent -query`; setParent $controlName; connectControl -fileName textureNameField $plugName; string $callback = "AEassignFilenameCB " + $plugName; string $command = "AEfilenameBrowser \"" + $callback + "\""; button -e -c $command browser; setParent $curParent; if ( $changedCommand != "" ) { string $buffer[]; tokenize($plugName,".",$buffer); string $cmd = $changedCommand+" \""+$buffer[0]+"\""; scriptJob -p $controlName -rp -ac $plugName $cmd; } }