// =========================================================================== // 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: Date // // Description: // // description // global proc int visorAddNewDiskFolderCallback( string $visor, string $path, string $type) // // Description: // This procedure is called by the file browser which was opened to allow the // user to choose which directory to open the disk folder in. // This procedure creates the folder and adds the directory to the list of // directories for which disk folders should exist. The list is stored as an // optionVar so that it will persist between sessions and across projects. // // Returns: // The return value is a boolean indicating whether the user's choice from // the file browser was valid. If it was invalid, the user will have the // opportunity to choose another. // { int $result; string $typeList[] = `file -q -typ $path`; if (size($typeList) > 0 && $typeList[0] == "directory") { // On NT when the file browser returns a directory path, it doesn't // have a "/" at the end. The visor ensures the path // ends in "/" regardless of OS. So in order for users to be able to // remove the folders they create on NT, it's just easier to ensure // the path ends in "/". // if(!`about -mac`){ if (substring($path, size($path), size($path)) != "/") { $path = ($path + "/"); } } visor -addFolder -type directory -openFolder true -path $path -name $path $visor; visor -rebuild $visor; // Add the folder to the optionVar which remembers the user's custom // disk folders // optionVar -stringValueAppend visorCustomDiskFolders $path; $result = true; } else { string $ok = (uiRes("m_visorAddNewDiskFolder.kOk")); string $msg = (uiRes("m_visorAddNewDiskFolder.kDirectoryError")); $msg = `format -s $path $msg`; confirmDialog -message $msg -button $ok -defaultButton $ok -parent projectViewerWindow; $result = false; } return $result; } global proc visorAddNewDiskFolder( string $visor) // // Description: // This procedure is called when the user chooses "Add new disk folder" from // the RMB menu in Visor. // This procedure opens a file browser to allow the user to choose which // directory the folder should correspond to. // The file browser will call the callback procedure above to actually create // the folder. // { // Set the directory to the users project area. // string $wsDir = dirname( `workspace -q -fn` ); if (`file -q -ex $wsDir`) { workspace -dir $wsDir; } string $chooseFolder = (uiRes("m_visorAddNewDiskFolder.kChooseFolder")); fileBrowser( ("visorAddNewDiskFolderCallback " + $visor), $chooseFolder, "", 4); }