// rd_Statesman.jsx // Copyright (c) 2005-2013 redefinery (Jeffrey R. Almasol). All rights reserved. // check it: www.redefinery.com // // Name: rd_Statesman // Version: 3.0 // // Description: // This script displays a palette with controls for capturing multiple // states of a composition's layer settings, and quickly recalling any of // them at a later time. You can capture and switch among up to 6 states // of layer features, specifically a layer's selection, A/V Features // settings, and Switches settings. // // To store the selected composition's layer state, select the layer // features from the Layer Features to Capture list, and then click the // upward-pointing arrow corresponding to one of the six State buttons. // // To recall a previously stored composition layer state, select the // "target" composition in the Project panel, and then click the State // button corresponding to the state you want to apply. The maximum // number of layers affected is determined by the lower number of layers // in the recalled state or in the current composition. // // Note: This version of the script requires After Effects CS5 // or later. It can be used as a dockable panel by placing the // script in a ScriptUI Panels subfolder of the Scripts folder, // and then choosing this script from the Window menu. // // Originally requested by Stu Maschwitz. // // Legal stuff: // This script is provided "as is," without warranty of any kind, expressed // or implied. In no event shall the author be held liable for any damages // arising in any way from the use of this script. // // In other words, I'm just trying to share knowledge with and help out my // fellow AE script heads, so don't blame me if my code doesn't rate. :-) // rd_Statesman() // // Description: // This function contains the main logic for this script. // // Parameters: // thisObj - "this" object. // // Returns: // Nothing. // (function rd_Statesman(thisObj) { // Globals var rd_StatesmanData = new Object(); // Store globals in an object rd_StatesmanData.scriptName = "rd: Statesman"; rd_StatesmanData.scriptTitle = rd_StatesmanData.scriptName + " v3.0"; rd_StatesmanData.strLayerFeatures = {en: "Layer Features to Capture:"}; rd_StatesmanData.states = new Array(); // Stores the comp states rd_StatesmanData.numStates = 6; // Number of states (buttons) rd_StatesmanData.strLayerStatesOpts = {en: '["General: Layer selection", "A/V Features: Video", "A/V Features: Audio", "A/V Features: Solo", "A/V Features: Lock", "Switches: Shy", "Switches: Cont. Rasterize / Collapse", "Switches: Quality", "Switches: Effect", "Switches: Frame Blending", "Switches: Motion Blur", "Switches: Adjustment Layer", "Switches: 3D Layer"]'}; rd_StatesmanData.strStateSet = {en: "^"}; rd_StatesmanData.strStates = {en: "States:"}; rd_StatesmanData.strHelp = {en: "?"}; rd_StatesmanData.strErrNoCompSel = {en: "Cannot perform operation. Please select or open a single composition in the Project panel, and try again."}; rd_StatesmanData.strMinAE100 = {en: "This script requires Adobe After Effects CS5 or later."}; rd_StatesmanData.strHelpText = { en: "Copyright (c) 2005-2013 redefinery (Jeffrey R. Almasol). \n" + "All rights reserved.\n" + "\n" + "This script displays a palette with controls for capturing multiple states of a composition's layer settings, and quickly recalling any of them at a later time. You can capture and switch among up to 6 states of layer features, specifically a layer's selection, A/V Features settings, and Switches settings.\n" + "\n" + "To store the selected composition's layer state, select the layer features from the Layer Features to Capture list, and then click the upward-pointing arrow corresponding to one of the six State buttons.\n" + "\n" + "To recall a previously stored composition layer state, select the \"target\" composition in the Project panel, and then click the State button corresponding to the state you want to apply. The maximum number of layers affected is determined by the lower number of layers in the recalled state or in the current composition.\n" + "\n" + "Note: This version of the script requires After Effects CS5 or later. It can be used as a dockable panel by placing the script in a ScriptUI Panels subfolder of the Scripts folder, and then choosing this script from the Window menu.\n" + "\n" + "Originally requested by Stu Maschwitz.\n" }; // rd_Statesman_localize() // // Description: // This function localizes the given string variable based on the current locale. // // Parameters: // strVar - The string variable's name. // // Returns: // String. // function rd_Statesman_localize(strVar) { return strVar["en"]; } // rd_Statesman_buildUI() // // Description: // This function builds the user interface. // // Parameters: // thisObj - Panel object (if script is launched from Window menu); null otherwise. // // Returns: // Window or Panel object representing the built user interface. // function rd_Statesman_buildUI(thisObj) { var pal = (thisObj instanceof Panel) ? thisObj : new Window("palette", rd_StatesmanData.scriptName, undefined, {resizeable:true}); if (pal !== null) { var res = "group { \ orientation:'column', alignment:['fill','fill'], \ header: Group { \ alignment:['fill','top'], \ title: StaticText { text:'" + rd_StatesmanData.scriptName + "', alignment:['fill','center'] }, \ help: Button { text:'" + rd_Statesman_localize(rd_StatesmanData.strHelp) +"', maximumSize:[30,20], alignment:['right','center'] }, \ }, \ r1: Group { \ alignment:['left','top'], \ statesLbl: StaticText { text:'" + rd_Statesman_localize(rd_StatesmanData.strStates) + "' }, "; for (var i=0; i layerStates.length) ? comp.numLayers : layerStates.length; var layer, layerInfo; // Apply the layer settings app.beginUndoGroup(rd_StatesmanData.scriptName); for (var i=0; i= 12.0) layer.samplingQuality = LayerSamplingQuality.BILINEAR; } else if ((layerInfo[7] === "3") && (parseFloat(app.version) >= 12.0)) { layer.quality = LayerQuality.BEST; layer.samplingQuality = LayerSamplingQuality.BICUBIC; } } catch (e) {} try { if (layerInfo[8] !== "-") layer.effectsActive = (layerInfo[8] === "1") ? true : false; } catch (e) {} try { if (layerInfo[9] !== "-") { if (layerInfo[9] === "0") layer.frameBlendingType = FrameBlendingType.NO_FRAME_BLEND; else if (layerInfo[9] === "1") layer.frameBlendingType = FrameBlendingType.FRAME_MIX; else if (layerInfo[9] === "2") layer.frameBlendingType = FrameBlendingType.PIXEL_MOTION; } } catch (e) {} try { if (layerInfo[10] !== "-") layer.motionBlur = (layerInfo[10] === "1") ? true : false; } catch (e) {} try { if (layerInfo[11] !== "-") layer.adjustmentLayer = (layerInfo[11] === "1") ? true : false; } catch (e) {} try { if (layerInfo[12] === "0") layer.threeDLayer = false; else if (layerInfo[12] === "1") { layer.threeDLayer = true; if (layer instanceof TextLayer) layer.threeDPerChar = false; } else if ((layerInfo[12] === "2") && (layer instanceof TextLayer)) // for per-char 3D text { layer.threeDLayer = true; layer.threeDPerChar = true; } } catch (e) {} // Note: Do the lock operation last, as it might restrict other operations if done earlier try { if (layerInfo[4] !== "-") layer.locked = (layerInfo[4] === "1") ? true : false; } catch (e) {} } app.endUndoGroup(); } // doHelp() // // Description: // This callback function displays the online help. // // Parameters: // None. // // Returns: // Nothing. // function doHelp() { var msg = rd_StatesmanData.scriptTitle + "\n" + rd_Statesman_localize(rd_StatesmanData.strHelpText); alert(msg, rd_StatesmanData.scriptName); } // main code: // // Prerequisites check if (parseFloat(app.version) < 10.0) alert(rd_Statesman_localize(rd_StatesmanData.strMinAE100), rd_StatesmanData.scriptName); else { // Build and show the console's floating palette var rdstPal = rd_Statesman_buildUI(thisObj); if (rdstPal !== null) { var stateStr, matches, layerStates; // Update UI values, if saved in the settings // Get the saved states data for (var i=0; i