Expressions/Scripts/Presets

Moderator: byronnash

 
Iaenic
Topic Author
Posts: 14
Joined: Thu Aug 09, 2012 11:29 am

Set Keyframe Influence

Tue Aug 12, 2014 2:41 pm

I'm attempting to make a toolbar that lets me change the incoming or outgoing velocities for all selected keyframes to set amounts (60%, 80%, 100% etc) with a single button press so I don't have to keep right clicking and going into the keyframe velocity window every time. The two problems i'm running into are:

1. How to loop through the currently selected keyframes on all currently active layers, and change just their influence (easing).
2. How to accommodate different types of properties, so it can change Position/Rotation/Scale keyframes simultaneously. Doing it manually through the keyframe velocity window only changes one property type at a time, and i'd love to have it be a single button press.

I spend a huge chunk of my day setting keyframes incoming influence to higher percentages. Id love to have a single button that does that. If anyone can help me get on the right track I would be most grateful.

Here's the docking panel I have for it so far, but doesn't work quite right yet.

EDIT: Getting closer by using what I learned from Paul Tuersley's delete duplicate keyframes script, but it edits more than the keyframes I have selected, and I want it to treat the speed as AE would if you were to "easy ease in" something and then set just the influence, instead of forcing the speed.

{
function EaseToolBar(thisObj) {
          function EaseToolBar_buildUI(thisObj) {
                    var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "Ease Tool Bar", undefined, {resizeable:true});
 
 res="group{orientation:'column', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
                              myStaticText: StaticText{text:'Outgoing Velocities'},\
                              myGroup: Group{orientation:'row', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
                                        myGroupItem1: Button{text:'< 33%'},\
                                        myGroupItem2: Button{text:'< 40%'},\
                                        myGroupItem3: Button{text:'< 60%'},\
                                        myGroupItem4: Button{text:'< 80%'},\
                                        myGroupItem5: Button{text:'< 100%'},\
                                                                                                              },\
                               myStaticText2: StaticText{text:'Incoming Velocities'},\
                              myGroup2: Group{orientation:'row', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
                                        myGroup2Item6: Button{text:'100% >'},\
                                        myGroup2Item7: Button{text:'80% >'},\
                                        myGroup2Item8: Button{text:'60% >'},\
                                        myGroup2Item9: Button{text:'40% >'},\
                                        myGroup2Item10: Button{text:'33% >'},\
                                                                      },\
                               }";
 
                    //Add resource string to panel
                    myPanel.grp = myPanel.add(res);
 
 
 myPanel.grp.myGroup.myGroupItem1.onClick = function(){


var activeItem = app.project.activeItem;

if (activeItem != null && activeItem instanceof CompItem) {
   var selectedProps = activeItem.selectedProperties;
   var y;
   
   app.beginUndoGroup("KeyFrame Easing");
   for (var x = 0; x < selectedProps.length; x++) {

      if (selectedProps[x].numKeys > 1) {     
         y = 1;
         while (y < selectedProps[x].numKeys) {
             var easeIn = new KeyframeEase(0.5, 50);
             var easeOut = new KeyframeEase(0.75, 85);
             var myProperty = selectedProps[x];
             myProperty.setTemporalEaseAtKey(y, [easeIn], [easeOut]);
             y ++;           
         }
      }
   }
   app.endUndoGroup();
}



     }
 
 
                    //Setup panel sizing and make panel resizable
                    myPanel.layout.layout(true);
                    //myPanel.grp.minimumSize = myPanel.grp.size;
                    //myPanel.layout.resize();
                    //myPanel.onResizing = myPanel.onResize = function () {this.layout.resize();}
                    return myPanel;
          }
 
 
          var EaseToolBarPal = EaseToolBar_buildUI(thisObj);
 
 
          if ((EaseToolBarPal != null) && (EaseToolBarPal instanceof Window)) {
                    EaseToolBarPal.center();
                    EaseToolBarPal.show();
                    }
          }
 
          EaseToolBar(this);
}




Who is online

Users browsing this forum: No registered users and 2 guests