// =========================================================================== // 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 blendShapeToggleVisibility(string $bsdName, string $id, string $ibIndex) // // Description: // Gather the clicked item and selected items. If selected items // contain the clicked item, toggle visibility of all the selected // items, else toggle visibility of only the clicked item. // { string $clickedAttr; if (endsWith($bsdName, "shapeEditorManager")) { // blendShape group $clickedAttr = $bsdName + ".blendShapeDirectory[" + stringRemovePrefix($id, "-") + "].directoryVisibility"; } else if ($id == "") { // blendShape $clickedAttr = $bsdName + ".targetDirectory[0].directoryVisibility"; } else if (startsWith($id, "-")) { // target group $clickedAttr = $bsdName + ".targetDirectory[" + stringRemovePrefix($id, "-") + "].directoryVisibility"; } else if ($ibIndex == "") { // target $clickedAttr = $bsdName + ".targetVisibility[" + $id + "]"; } else { // inbetween target $clickedAttr = $bsdName + ".inbetweenInfoGroup[" + $id + "].inbetweenInfo[" + $ibIndex + "].inbetweenVisibility"; } string $selectedAttrs[]; // blendShape group string $selectedBsdGL[] = getShapeEditorTreeviewSelection(0); for ($bsdG in $selectedBsdGL) $selectedAttrs[size($selectedAttrs)] = "shapeEditorManager.blendShapeDirectory[" + stringRemovePrefix($bsdG, "-") + "].directoryVisibility"; // blendShape string $selectedBsdL[] = getShapeEditorTreeviewSelection(1); for ($bsd in $selectedBsdL) $selectedAttrs[size($selectedAttrs)] = $bsd + ".targetDirectory[0].directoryVisibility"; // target group string $selectedTgtGL[] = getShapeEditorTreeviewSelection(3); for ($tgtG in $selectedTgtGL) { string $buffer[]; tokenize($tgtG, ".", $buffer); if (size($buffer) == 2) $selectedAttrs[size($selectedAttrs)] = $buffer[0] + ".targetDirectory[" + stringRemovePrefix($buffer[1], "-") + "].directoryVisibility"; } // target string $selectedTgtL[] = getShapeEditorTreeviewSelection(4); for ($tgt in $selectedTgtL) { string $buffer[]; tokenize($tgt, ".", $buffer); if (size($buffer) == 2) $selectedAttrs[size($selectedAttrs)] = $buffer[0] + ".targetVisibility[" + $buffer[1] + "]"; } // in-between target string $selectedIbTgtL[] = getShapeEditorTreeviewSelection(6); for ($ibTgt in $selectedIbTgtL) { string $buffer[]; tokenize($ibTgt, ".", $buffer); if (size($buffer) == 3) $selectedAttrs[size($selectedAttrs)] = $buffer[0] + ".inbetweenInfoGroup[" + $buffer[1] + "].inbetweenInfo[" + $buffer[2] + "].inbetweenVisibility"; } string $visibilityAttrs[]; if (!stringArrayContains($clickedAttr, $selectedAttrs)) $visibilityAttrs[0] = $clickedAttr; else $visibilityAttrs = $selectedAttrs; int $invisibleParentCount = blendShapeTurnOnParentsVisibility($visibilityAttrs); int $visible = 1; for ($attr in $visibilityAttrs) { int $attrVisible = `getAttr $attr`; if (!$attrVisible) $visible = 0; if (!$visible) break; } if ($visible && $invisibleParentCount > 0) return; $visible = !$visible; for ($attr in $visibilityAttrs) { int $attrVisible = `getAttr $attr`; if ($attrVisible != $visible) setAttr $attr $visible; } }