// =========================================================================== // 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. // =========================================================================== // Procedure Name: // updateUvSetEditor // // Description: // Updates the uvSetEditor when called. When the uvSetEditor is created // it creates a scriptJob that is tied to it that cals this when the selection // changes. This is also called from uvSetEditCmd. // // Input Arguments: // None. // // Return Value: // None. // global proc updateUvSetEditor( ) { // typically, user will have transform selected so find mesh shapes // string $objects[] = `listRelatives -s -fullPath -type "mesh" -noIntermediate`; // if there is nothing, check to see if shapes are selected // if (!`size $objects`) $objects = `ls -sl -type "mesh"`; // if there is still nothing, check to see if components are selected // if (!`size $objects`) $objects = `listRelatives -p -fullPath -type "mesh"`; // clear the set list // textScrollList -e -ra uvSetList; // if there are meshes, populate the list with the cpv sets // from the first selected mesh // if (`size $objects`){ string $sets[] = `polyUVSet -pi 1 -q -allUVSets $objects[0]`; for( $set in $sets ) { string $perInstUVSet[] = `polyUVSet -uvSet $set -q -pi $objects[0]`; if (size($perInstUVSet[0]) > 0) { $set = $perInstUVSet[0]; } else { continue; } textScrollList -e -a $set uvSetList; } //***need to add controls for enable/disable state of buttons // select the current uv set // string $currentUVSet[] = `polyUVSet -q -currentPerInstanceUVSet $objects[0]`; if( `size $currentUVSet` > 0 ) textScrollList -e -si $currentUVSet[0] uvSetList; } } // Procedure Name: // builduvSetEditorContextHelpItems // // Description: // Creates the help menu and items for the uvSetEditor. // // Input Arguments: // $nameRoot - name to use as the root of all item names // $menuParent - the name of the parent of this menu // // Return Value: // None // global proc builduvSetEditorContextHelpItems(string $nameRoot, string $menuParent) { menuItem -label (uiRes("m_uvSetEditor.kHelpOnUVSetEditor")) -enableCommandRepeat false -command "showHelp uvSetEditor"; } // Procedure Name: // uvSetEditor // // Description: // Creates the uvSetEditor for editting multiple CPV sets. // // Input Arguments: // None. // // Return Value: // None. // global proc uvSetEditor( ) { if( `window -exists uvSetEditor` ) { deleteUI -window uvSetEditor; } // GG: don't hardcode the HEIGHT! It doesn't work X-platform window -title (uiRes("m_uvSetEditor.kUVSetEditor")) -menuBar true -w 223 -s true uvSetEditor; addContextHelpProc "uvSetEditor" "builduvSetEditorContextHelpItems"; menu -label (uiRes("m_uvSetEditor.kPolyUVsPerInstance")); string $cmd = "SelectSharedUVInstances"; menuItem -label (uiRes("m_uvSetEditor.kPolyUVSelectShared")) -annotation (getRunTimeCommandAnnotation($cmd)) -command $cmd; $cmd = "ShareUVInstances"; menuItem -label (uiRes("m_uvSetEditor.kPolyUVShareInstances")) -annotation (getRunTimeCommandAnnotation($cmd)) -command $cmd; setParent -menu ..; doHelpMenu("uvSetEditor", "uvSetEditor"); formLayout colorEditorForm; textScrollList -ams true -deleteKeyCommand "string $selSets[] = `textScrollList -q -si uvSetList`; uvSetEditCmd delete $selSets" -doubleClickCommand "string $selSets[] = `textScrollList -q -si uvSetList`; uvSetEditCmd rename $selSets" -selectCommand "string $selSets[] = `textScrollList -q -si uvSetList`; uvSetEditCmd setCurrent $selSets" uvSetList; separator scrollButtonsSeparator; columnLayout uvSetEditorButtonLayout; button -h 26 -w 80 -label (uiRes("m_uvSetEditor.kPolyNewUVSet")) -annotation (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsCreateUVSetAnnot")) -enable true -c "string $selSets[] = `textScrollList -q -si uvSetList`; uvSetEditCmd new $selSets" newButton; button -h 26 -w 80 -label (uiRes("m_uvSetEditor.kPolyRenameUVSet")) -annotation (getRunTimeCommandAnnotation("RenameCurrentUVSet")) -c "string $selSets[] = `textScrollList -q -si uvSetList`; uvSetEditCmd rename $selSets" -enable true renameButton; button -h 26 -w 80 -label (uiRes("m_uvSetEditor.kPolyDeleteUVSet")) -annotation (getRunTimeCommandAnnotation("DeleteCurrentUVSet")) -c "string $selSets[] = `textScrollList -q -si uvSetList`; uvSetEditCmd delete $selSets" -enable true deleteButton; button -h 26 -w 80 -label (uiRes("m_uvSetEditor.kPolyCopyUVSet")) -annotation (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsCopyIntoNewUVSetAnnot")) -c "string $selSets[] = `textScrollList -q -si uvSetList`; uvSetEditCmd copy $selSets" -enable true copyButton; button -h 26 -w 80 -label (uiRes("m_uvSetEditor.kPolyPropagateUVSet")) -annotation (uiRes("m_uvSetEditor.kPolyPropagateUVSetAnnot")) -c "string $selSets[] = `textScrollList -q -si uvSetList`; uvSetEditCmd propagate $selSets" -enable true propagateButton; button -h 26 -w 80 -label (uiRes("m_uvSetEditor.kPolyUnmappedUVSet")) -annotation (uiRes("m_uvSetEditor.kPolyUnmappedUVSetAnnot")) -c ( "SelectUnmappedFaces" ) -enable true unmappedButton; setParent ..; button -h 26 -w 80 -label (uiRes("m_uvSetEditor.kPolyUpdateUVSet")) -c "updateUvSetEditor" updateButton; button -h 26 -w 80 -label (uiRes("m_uvSetEditor.kPolyCloseUVSet")) -c "deleteUI -window uvSetEditor" closeButton; setParent ..; formLayout -e -af uvSetList top 5 -ac uvSetList right 5 uvSetEditorButtonLayout -af uvSetList left 5 -ac uvSetList bottom 5 scrollButtonsSeparator -af uvSetEditorButtonLayout top 5 -af uvSetEditorButtonLayout right 5 -an uvSetEditorButtonLayout left -ac uvSetEditorButtonLayout bottom 5 scrollButtonsSeparator -af scrollButtonsSeparator left 0 -af scrollButtonsSeparator right 0 -ac scrollButtonsSeparator bottom 5 updateButton -an scrollButtonsSeparator top -af updateButton left 5 -af updateButton bottom 5 -ap updateButton right 3 50 -an updateButton top -ap closeButton left 2 50 -af closeButton bottom 5 -af closeButton right 5 -an closeButton top colorEditorForm; // Create script jobs to keep the uv set editor up to date // when the selection changes // scriptJob -parent "uvSetEditor" -event "SelectionChanged" "updateUvSetEditor"; scriptJob -parent "uvSetEditor" -event "Undo" "updateUvSetEditor"; scriptJob -parent "uvSetEditor" -event "Redo" "updateUvSetEditor"; updateUvSetEditor; showWindow uvSetEditor; }