// =========================================================================== // 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. // =========================================================================== // First creation of the assembly namespace widgets in the attribute editor. global proc AEassemblyNamespaceNew(string $attrName) { rowLayout -numberOfColumns 1 -columnAttach 1 "left" 0 -adjustableColumn 1; textFieldGrp -label (uiRes("m_AEassemblyNamespaceUtil.kAEassemblyNamespace")) assemblyNamespaceValue; iconTextButton -i1 "namespaceEditor.png" -ann (uiRes("m_AEassemblyNamespaceUtil.kAEOpenNSEditor")) -parent assemblyNamespaceValue assemblyNamespaceEditor; setParent ..; AEassemblyNamespaceReplace($attrName); } // Update and replace the assembly namespace. global proc AEassemblyNamespaceReplace(string $attrName) { string $nodeName = `plugNode $attrName`; int $editable = !`getAttr -lock $attrName`; // #1 is the syntax to obtain the value of the control at the time // the command is issued (avoids querying the control). textFieldGrp -edit -text `getAttr $attrName` -changeCommand ("AEassemblyChangeAttrNamespace \"" + $attrName + "\"" + "\"#1\"") -editable $editable assemblyNamespaceValue; iconTextButton -edit -command "AEassemblyShowNamespaceEditor" assemblyNamespaceEditor; } // Change the namespace attribute value. global proc AEassemblyChangeAttrNamespace(string $attrName, string $namespace) { // check if the new name has illegal characters // if so, show an error and reset the UI if( !isValidString($namespace, "([a-zA-Z]+)([a-zA-Z0-9_])*") ) { textFieldGrp -edit -text `getAttr $attrName` assemblyNamespaceValue; string $errorMsg = (uiRes("m_AEassemblyNamespaceUtil.kInvalidNamespace")); error(`format -s $namespace $errorMsg`); } else { // Set the new namespace. setAttr $attrName -type "string" $namespace; // re-select the assembly node to stay in the attribute editor. select -r `plugNode $attrName`; } } // Show namespace editor. global proc AEassemblyShowNamespaceEditor() { if (!`window -exists namespaceEditor`) { namespaceEditor; } }