// =========================================================================== // 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. // =========================================================================== // // // // // containerAutobind // // // None // // // This script performs autobind operations on a container. // // // string $container, the container to use, or "" to use selected // string $bindingSet, the bindingSet to use, or "" have default // bindingSet determined automatically // int $autobindAll, process all published names // (by default only unbound names are processed) // int $force, forcibly unbind previously bound attributes // if they are not matched. By default unmatched // names will be skipped. // // // // autobind myContainer using binding set "MyBindings". // // Since all option is used, all published names (bound and unbound) // // will be processed. // // Since force option is used, any unmatched name will be unbound. // containerAutobind(myContainer, "MyBindings", 1, 1); // // // autobind myContainer using a default binding set // // Since all option is not set, only unbound names will be processed. // containerAutobind(myContainer, "", 0, 0); // // // autobind myContainer using the default binding set. // // All published names will be processed. // // Because force option is not used, names not // // matched will be left with their current bindings // string $bindingSet = containerDefaultBindingSet(); // containerAutobind(myContainer, $bindingSet, 1, 0); // // // global proc containerAutobind(string $container, string $bindingSetIn, int $autobindAll, int $force) { string $defaultBindingSet = containerDefaultBindingSet(); string $bSets[] = `containerBind -q -bindingSetList $container`; // If the container has no binding sets issue a warning if (!size($bSets)) { string $msg = (uiRes("m_containerAutobind.kNoBindingSets")); warning($msg); return; } string $bsName = ""; // If caller specified a binding set, use it if (size($bindingSetIn)) { // Make sure it exists if (stringArrayContains($bindingSetIn, $bSets)) { $bsName = $bindingSetIn; } else { string $fmt = (uiRes("m_containerAutobind.kInvalidBindingSet")); string $msg = `format -stringArg $bindingSetIn -stringArg $container $fmt`; error($msg); } } // Otherwise, look for default binding set name and use that else { // Try to use default binding set name if (stringArrayContains($defaultBindingSet, $bSets)) { $bsName = $defaultBindingSet; } // Otherwise, use the first binding set found on the container else { $bsName = $bSets[0]; } string $fmt = (uiRes("m_containerAutobind.kUsingBindingSet")); string $msg = `format -stringArg $bsName $fmt`; warning($msg); } // Set up the command with its options string $forceFlag = ""; string $bindAllFlag = ""; if ($force) { $forceFlag = "-force"; } if ($autobindAll) { $bindAllFlag = "-allNames"; } string $cmdFmt = "containerBind -bindingSet ^1s ^2s ^3s ^4s"; string $cmd = `format -stringArg $bsName -stringArg $forceFlag -stringArg $bindAllFlag -stringArg $container $cmdFmt`; evalEcho($cmd); // Refresh any asset editor for this container that might be displayed refreshAssetWindows( "", $container ); return; }