// =========================================================================== // 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: October 9, 2016 // // Procedure Name: // texCheckSelection // // Description: // UV workflow function used for checking for valid selections. // // Input Arguments // selectionType - String - What selection type to validate. // // Return Value: // None - The procedure errorCode is called for managing error messages. // // Notes: // This script is part of the implementation of Nightshade UV Editor into // Autodesk Maya. This script is sourced by other scripts. Do not run it // directly. // // =========================================================================== global proc texCheckSelection(string $selectionType) { string $selection[]; switch($selectionType){ case "any": // Any components $selection = `filterExpand -sm 12 -sm 31 -sm 32 -sm 34 -sm 35`; if (size($selection) == 0){ error((uiRes("m_texCheckSelection.kNoSelection"))); } break; case "mesh": // Meshes $selection = `filterExpand -selectionMask 12`; if (size($selection) == 0){ error((uiRes("m_texCheckSelection.kNoMesh"))); } break; case "comps": // Components only $selection = `filterExpand -sm 31 -sm 32 -sm 34 -sm 35`; if (size($selection) == 0){ error((uiRes("m_texCheckSelection.kNoComponents"))); } break; case "mesh1": // ONE mesh only $selection = `filterExpand -selectionMask 12`; if (size($selection) != 1){ error((uiRes("m_texCheckSelection.kNoSingleMesh"))); } break; case "face": // Faces $selection = `filterExpand -selectionMask 34`; if (size($selection) == 0){ error((uiRes("m_texCheckSelection.kNoFace"))); } break; case "face1": // ONE face only - Unused atm $selection = `filterExpand -selectionMask 34`; if (size($selection) != 1){ error((uiRes("m_texCheckSelection.kNoSingleFace"))); } break; case "faceMesh": // Faces or meshes $selection = `filterExpand -sm 12 -sm 34`; if (size($selection) == 0){ error((uiRes("m_texCheckSelection.kNoFaceMesh"))); } break; case "faceUV": // Faces or UVs $selection = `filterExpand -sm 34 -sm 35`; if (size($selection) == 0){ error((uiRes("m_texCheckSelection.kNoFaceUV"))); } break; case "edge": // Edges $selection = `filterExpand -selectionMask 32`; if (size($selection) == 0){ error((uiRes("m_texCheckSelection.kNoEdge"))); } break; case "edgeUV": // Edges or UVs $selection = `filterExpand -sm 32 -sm 35`; if (size($selection) == 0){ error((uiRes("m_texCheckSelection.kNoEdgeUV"))); } break; case "UV": // UVs $selection = `filterExpand -selectionMask 35`; if (size($selection) == 0){ error((uiRes("m_texCheckSelection.kNoUV"))); } break; case "UV2": // TWO UVs only $selection = `filterExpand -selectionMask 35`; if (size($selection) != 2){ error((uiRes("m_texCheckSelection.kNoTwoUV"))); } break; case "meshUV": // Meshes or UVs $selection = `filterExpand -sm 12 -sm 35`; if (size($selection) == 0){ error((uiRes("m_texCheckSelection.kNoMeshUV"))); } break; case "multi": // Selection spans over multiple shells $selection = `ls -selection`; string $selectedUVs[] = `polyListComponentConversion -toUV`; // Expand to entire shells polySelectConstraint -mode 2 -shell 1 -type 0x0010; polySelectConstraint -disable; // Get one single UV from selectedUVs and convert to just ONE shell select $selectedUVs[0]; polySelectConstraint -mode 2 -shell 1 -type 0x0010; polySelectConstraint -disable; break; } }