// =========================================================================== // 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. // =========================================================================== // proc string findContainerToUse() { // find the selected container // string $container[] = `ls -sl -containers`; if (size($container) == 0) { // No container was selected. See if there is a current container. // string $currentContainer = `container -q -current`; if ("" != $currentContainer) { $container[0] = $currentContainer; } if (size($container) == 0) { // See if some of the selected objects are in a container. // string $sel[] = `ls -sl`; for ($obj in $sel) { string $foundContainer = `container -q -fc $obj`; if (size($foundContainer) > 0) { if (size($container) == 0) { $container[0] = $foundContainer; } else if ($foundContainer != $container[0]) { clear($container); break; } } } } } if (size($container) == 0) { error((uiRes("m_doAddToContainer.kMustSelectContainer"))); } else if (size($container) == 2) { // If 2 are selected, then use the latter as the target // return $container[1]; } else if (size($container) > 2) { error((uiRes("m_doAddToContainer.kMoreThanOneContainer"))); } return $container[0]; } // Procedure Name: // doAddToContainer // // Description: // Add selected nodes to the selected container // // Input Arguments: // $version: The version of this option box. Used to know how to // interpret the $args array. // "1" : $name // // $args // Version 1 // [0] $cmd : the container command // global proc doAddToContainer(int $version, string $args[]) { // currently there is only one version of this proc so we don't need // to check the version # // string $cmd = $args[0]; // find the selected container // string $container = findContainerToUse(); select -d $container; $cmd += ("-addNode `ls -sl` "+$container); if (catch(`evalEcho $cmd`)) { select -add $container; } }