// =========================================================================== // 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 addAEFilter( string $newType ) // // Description: // A callback to define a new type based filter for the AE // { if( $newType == "" ){ // prompt for node type // string $OK = (uiRes("m_addAEFilter.kOK")); string $cancel = (uiRes("m_addAEFilter.kCancel")); string $result = `promptDialog -title (uiRes("m_addAEFilter.kDefineNewFilterType")) -message (uiRes("m_addAEFilter.kEnterNewFilterType")) -text (uiRes("m_addAEFilter.kNodeType")) -button $OK -button $cancel -defaultButton $OK -cancelButton $cancel -dismissString $cancel`; // If the result was "OK", then proceed // if ( $result == $OK ) { // Get the tag the user entered // $newType = `promptDialog -q`; } } if( $newType == "" ){ warning((uiRes("m_addAEFilter.kNoType"))); return; } string $filterTypes[]; if( `optionVar -exists activeAEShowFilterTypes` ){ $filterTypes = `optionVar -query activeAEShowFilterTypes`; } int $numFilterTypes = size($filterTypes); int $filterStates[]; if( `optionVar -exists activeAEShowFilterStates` ){ $filterStates = `optionVar -query activeAEShowFilterStates`; } int $numFilterStates = size($filterStates); if( $numFilterTypes == 0 ){ // First one, just add it. // optionVar -sva activeAEShowFilterTypes ""; optionVar -iva activeAEShowFilterStates 1; optionVar -sva activeAEShowFilterTypes $newType; optionVar -iva activeAEShowFilterStates 1; } else if( strcmp( $newType, $filterTypes[$numFilterTypes-1] ) > 0 ){ // New type is last, so we can simply append it. // optionVar -sva activeAEShowFilterTypes $newType; optionVar -iva activeAEShowFilterStates 1; } else { // Insert type, if it hasn't already been added // if( stringArrayContains( $newType, $filterTypes ) ){ warning((uiRes("m_addAEFilter.kAlreadyDefined"))); return; } // We need to rebuild the option var to keep it sorted // optionVar -remove activeAEShowFilterTypes; optionVar -remove activeAEShowFilterStates; int $addNewType = true; int $filterIndex = 0; while( $filterIndex < $numFilterTypes ){ string $currType = $filterTypes[$filterIndex]; if( $addNewType ){ if( strcmp( $currType, $newType ) > 0 ){ // We need to add the new type // optionVar -sva activeAEShowFilterTypes $newType; optionVar -iva activeAEShowFilterStates 1; $addNewType = false; } } optionVar -sva activeAEShowFilterTypes $filterTypes[$filterIndex]; int $show = 1; // Default value is 1 (i.e., on ) if( $filterIndex < $numFilterStates ){ $show = $filterStates[$filterIndex]; } optionVar -iva activeAEShowFilterStates $show; $filterIndex++; } } updateAEshowAllButton(); global string $gAEFocusNode; if( $gAEFocusNode != "" ){ updateAE $gAEFocusNode; } }