// rd_SnapDecisions.jsx // Copyright (c) 2007-2015 redefinery (Jeffrey R. Almasol). All rights reserved. // check it: www.redefinery.com // // Name: rd_SnapDecisions // Version: 1.2 // // Description: // This script displays a palette with controls for snapping keyframes // (all on a layer), layer markers, and even layer in/out points (by trimming) // to frame times based on the composition's frame rate. When not on a frame // boundary, they can be snapped to the nearest, previous, or next frame. // // 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. // // Enhancements requested by Kevin Snyder. // // 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_SnapDecisions() // // Description: // This function contains the main logic for this script. // // Parameters: // thisObj - "this" object. // // Returns: // Nothing. // (function rd_SnapDecisions(thisObj) { // Globals var rd_SnapDecisionsData = new Object(); // Store globals in an object rd_SnapDecisionsData.scriptName = "rd: Snap Decisions"; rd_SnapDecisionsData.scriptTitle = rd_SnapDecisionsData.scriptName + " v1.2"; rd_SnapDecisionsData.strSnapLbl = {en: "Snap:"}; rd_SnapDecisionsData.strLayerIOLbl = {en: "Layer In/Out Points (Trim)"}; rd_SnapDecisionsData.strKfsLbl = {en: "Keyframes"}; //rd_SnapDecisionsData.strKfsOpts = {en: ["Selected Properties", "All Properties"]}; rd_SnapDecisionsData.strLayerMarkersLbl = {en: "Layer Markers"}; rd_SnapDecisionsData.strToLbl = {en: "To:"}; rd_SnapDecisionsData.strToOpts = {en: ["Nearest Frame", "Previous Frame", "Next Frame"]}; rd_SnapDecisionsData.strAffectLbl = {en: "On:"}; rd_SnapDecisionsData.strAffectOpts = {en: ["Selected Layers in Comp", "All Layers in Comp"]}; rd_SnapDecisionsData.strSnap = {en: "Snap"}; rd_SnapDecisionsData.strHelp = {en: "?"}; rd_SnapDecisionsData.strErrNoCompSel = {en: "Cannot perform operation. Please select or open a single composition in the Project panel, and try again."}; rd_SnapDecisionsData.strErrNoLayerSel = {en: "Cannot perform operation. Please select at least one layer, and try again."}; rd_SnapDecisionsData.strMinAE100 = {en: "This script requires Adobe After Effects CS5 or later."}; rd_SnapDecisionsData.strHelpText = { en: "Copyright (c) 2007-2015 redefinery (Jeffrey R. Almasol). \n" + "All rights reserved.\n" + "\n" + "This script displays a palette with controls for snapping keyframes (all on a layer), layer markers, and even layer in/out points (by trimming) to frame times based on the composition's frame rate. When not on a frame boundary, they can be snapped to the nearest, previous, or next frame.\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" + "Enhancements requested by Kevin Snyder." }; // rd_SnapDecisions_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_SnapDecisions_localize(strVar) { return strVar["en"]; } // rd_SnapDecisions_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_SnapDecisions_buildUI(thisObj) { var pal = (thisObj instanceof Panel) ? thisObj : new Window("palette", rd_SnapDecisionsData.scriptName, undefined, {resizeable:true}); if (pal !== null) { var res = """group { orientation:'column', alignment:['fill','top'], alignChildren:['fill','top'], header: Group { alignment:['fill','top'], title: StaticText { text:'""" + rd_SnapDecisionsData.scriptName + """', alignment:['fill','center'] }, help: Button { text:'""" + rd_SnapDecisions_localize(rd_SnapDecisionsData.strHelp) + """', maximumSize:[30,20], alignment:['right','center'] }, }, layerIO: Group { orientation:'row', alignChildren:['fill','center'], snapLbl: StaticText { text:'""" + rd_SnapDecisions_localize(rd_SnapDecisionsData.strSnapLbl) + """', alignment:['left','top'] }, lbl: Checkbox { text:'""" + rd_SnapDecisions_localize(rd_SnapDecisionsData.strLayerIOLbl) + """', alignment:['left','top'], value:true }, }, kfs: Group { orientation:'row', alignChildren:['fill','center'], spacer: Group { alignment:['left','center'] }, lbl: Checkbox { text:'""" + rd_SnapDecisions_localize(rd_SnapDecisionsData.strKfsLbl) + """', alignment:['left','center'], value:true }, }, layerMarkers: Group { orientation:'row', alignChildren:['fill','center'], spacer: Group { alignment:['left','center'] }, lbl: Checkbox { text:'""" + rd_SnapDecisions_localize(rd_SnapDecisionsData.strLayerMarkersLbl) + """', alignment:['left','center'], value:true }, }, snapTo: Group { lbl: StaticText { text:'""" + rd_SnapDecisions_localize(rd_SnapDecisionsData.strToLbl) + """', alignment:['left','center'] }, lst: DropDownList { properties:{ }, alignment:['fill','center'], preferredSize:[-1,20] }, }, affectLayers: Group { lbl: StaticText { text:'""" + rd_SnapDecisions_localize(rd_SnapDecisionsData.strAffectLbl) + """', alignment:['left','center'] }, lst: DropDownList { properties:{ }, alignment:['fill','center'], preferredSize:[-1,20] }, }, btns: Group { alignment:['right','bottom'], snap: Button { text:'""" + rd_SnapDecisions_localize(rd_SnapDecisionsData.strSnap) + """', preferredSize:[-1,20] }, }, }"""; pal.grp = pal.add(res); //var listItems = rd_SnapDecisions_localize(rd_SnapDecisionsData.strKfsOpts); //for (var i=0; i 0) prop.removeKey(1); // Snap keyframe times for (var k=0; k