// =========================================================================== // 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 activateTopoSymmetry(string $component, string $originalSelection[], string $originalHilite[], string $compSelType, string $postCmd, int $clearAfterPost) { string $typedObject[]; // Polygon Edge $typedObject = `filterExpand -expand on -selectionMask 32 $component`; if (size($typedObject) > 0) { symmetricModelling -topoSymmetry 1; } // Restore component mask if (size($compSelType) > 0) { string $selCmd = "selectType "; int $objectMode = `selectMode -q -o`; if ($objectMode) $selCmd += "-ocm"; if ($compSelType == "none") { $selCmd += "-alc 0"; } else { $selCmd += "-" + $compSelType + " 1"; } eval($selCmd); } // Restore original hilite if (size($originalHilite[0]) > 0) { hilite $originalHilite; } // Restore original selection if (size($originalSelection[0]) > 0) { select -r -sym $originalSelection; } else { select -clear; } // If a command is specified then perform the command and disable symmetry if ($postCmd != "") { eval($postCmd); if ($clearAfterPost > 0) { symmetricModelling -e -ts 0 -s 0; if (size($originalSelection[0]) > 0) { select -r $originalSelection; } else { select -clear; } } } } global proc pickTopoSymmetryEdge(string $postCmd, int $clearAfterPost) { string $ctx; string $currentSelection[] = `ls -sl`; string $currentHilite[] = `ls -hl`; int $objectMode = `selectMode -q -o`; string $ocm = ($objectMode ? "-ocm " : ""); int $disableSymmetry = `symmetricModelling -q -s`; // Save component selectType string $compSelType = ""; string $selQuery = "selectType -q " + $ocm; if (eval($selQuery + "-vertex")) $compSelType = "vertex"; else if (eval($selQuery + "-edge")) $compSelType = "edge"; else if (eval($selQuery + "-facet")) $compSelType = "facet"; else if (eval($selQuery + "-meshComponents")) $compSelType = "meshComponents"; else if (eval($selQuery + "-cv")) $compSelType = "cv"; else $compSelType = "none"; // Build setup command string $startCmd = ""; if (size($currentHilite) == 0) $startCmd += "hilite;"; $startCmd += "selectType " + $ocm + "-alc 0;"; $startCmd += "selectType " + $ocm + "-edge 1;"; $startCmd += "select -clear;"; if ($disableSymmetry) $startCmd += "symmetricModelling -s 0;"; // Build final command string $cmd = "activateTopoSymmetry($Selection1[0]"; $cmd += ", {\"" + stringArrayToString($currentSelection, "\", \"") + "\"}"; $cmd += ", {\"" + stringArrayToString($currentHilite, "\", \"") + "\"}"; $cmd += ", \"" + $compSelType + "\""; $cmd += ", \"" + $postCmd + "\""; $cmd += ", " + $clearAfterPost ; $cmd += ");"; string $pointMsg = (uiRes("m_pickTopoSymmetryEdge.kOrientMoveManipComponentPrompt")); $ctx = `scriptCtx -title (uiRes("m_pickTopoSymmetryEdge.kOrientMoveManipComponentMoveTo")) -toolStart $startCmd -finalCommandScript $cmd -showManipulators off -totalSelectionSets 1 -setSelectionCount 1 // Types of point allowed in selection // ----------------------------------- -controlVertex 0 -editPoint 0 -polymeshVertex 0 -polymeshEdge 1 -polymeshFace 0 -locatorXYZ 0 -locator 0 -joint 0 -jointPivot 0 -scalePivot 0 -rotatePivot 0 -subdivMeshPoint 0 -latticePoint 0 -particle 0 -motionTrailPoint 0 -motionTrailTangent 0 // ----------------------------------- -setNoSelectionPrompt $pointMsg -setNoSelectionHeadsUp $pointMsg -exitUponCompletion on -setAutoComplete on`; setToolTo $ctx; }