// =========================================================================== // 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. // =========================================================================== global proc polyBestPlaneTexturingTool() { // Get original selection and retrieve the selected UV shells string $selection[] = `ls -selection`; string $compSelType = `getComponentMask`; string $selectedFaces[] = `filterExpand -selectionMask 34`; if (size($selectedFaces) == 0) { // If Convert Selection is ON, try to convert the current selection to faces. int $val = `optionVar -q polyAutoConvertAction`; if ( 1 == $val ) { PolySelectConvert 1; $selectedFaces = `filterExpand -selectionMask 34`; } // Check if the set of faces is still empty. if (size($selectedFaces) == 0) { error((uiRes("m_polyBestPlaneTexturingTool.kNoFacesSelected"))); return; } } // Build final command string $cmd = "performBestPlaneTexturing("; $cmd += "{\"" + stringArrayToString($selectedFaces, "\", \"") + "\"}"; $cmd += ", $Selection1);"; // Build finish command string $finishCmd = "polyBestPlaneTexturingContextFinish("; $finishCmd += "{\"" + stringArrayToString($selection, "\", \"") + "\"}"; $finishCmd += ", \"" + $compSelType + "\""; $finishCmd += ");"; // Create bestPlaneTexturing Context // string $ctx = `scriptCtx -i1 "bestPlaneTxt.png" -baseClassName "bestPlaneTexturing" -escToQuit 1 -title (uiRes("m_polyBestPlaneTexturingTool.kBestPlaneTexturingTool")) -totalSelectionSets 1 -cumulativeLists false -exitUponCompletion true -fcs $cmd -toolStart "polyBestPlaneTexturingContextStart" -toolFinish $finishCmd -setAutoComplete false -setSelectionCount 0 -pf true -pv true -cv true -xyz true`; setToolTo $ctx; } global proc polyBestPlaneTexturingContextStart() { string $currentHilite[] = `ls -hl`; string $ocm = (`selectMode -q -o` ? "-ocm " : ""); string $startCmd = ""; if (size($currentHilite) == 0) $startCmd += "hilite;"; $startCmd += "selectType " + $ocm + "-alc 0;"; $startCmd += "selectType " + $ocm + "-facet 1;"; $startCmd += "select -clear;"; eval($startCmd); int $prevValue = `selectPref -q -selectTypeChangeAffectsActive`; optionVar -iv PolyBestPlaneTexturingContextBackup $prevValue; selectPref -selectTypeChangeAffectsActive false; inViewMessage -amg (uiRes("m_polyBestPlaneTexturingTool.kSelectFaces")) -pos topCenter -fot 0; } global proc polyBestPlaneTexturingContextFinish(string $selection[], string $compSelType) { inViewMessage -clear topCenter; int $prevValue = `optionVar -q PolyBestPlaneTexturingContextBackup`; selectPref -selectTypeChangeAffectsActive $prevValue; //restore the original component mask setComponentMask($compSelType); //select the original selection select -replace $selection; }