I wrote a little script to turn off depth of field quickly - but it doesn't work in every AE project.
If I start a new project, make a new comp and put a bunch of layers and a camera in there it works properly. If I load older projects (which are set up nearly identical) and run the script nothing happens.
Can somebody tell me what's going wrong?
Here is my script:
Code: Select all
// Dof Quicktoggle
// Version 1.0
// Changelog:
// initial release
// Author: M. Bürster for Haus&Gross
//
var scriptTitle = "DoF Quicktoggle";
var myComp = app.project.selection;
var myCamera
var myPalette = buildUI(this);
if (myPalette != null && myPalette instanceof Window) {
myPalette.show();
}
function buildUI (thisObject) {
if (thisObject instanceof Panel) {
var myPalette = thisObject;
} else {
var myPalette = new Window ("palette", scriptTitle, undefined, {resizeable:true});
}
if (myPalette != null ) {
var res =
"Group { \
orientation: 'column', \
alignment: ['fill','fill'], \
alignChildren: ['left','top'], \
btnturnoff: Button {text:'DoF off', alignment: ['left','top']}, \
btnturnon: Button {text:'DoF on', alignment: ['left','top']}, \
}";
myPalette.grp = myPalette.add(res);
myPalette.layout.layout(true);
myPalette.layout.resize();
myPalette.grp.btnturnoff.onClick = function () {
for (var i = 0; i < myComp.length; i++) {
myCamera = myComp[i].activeCamera;
myCamera.depthOfField.setValue([0]);
}
}
myPalette.grp.btnturnon.onClick = function () {
for (var i = 0; i < myComp.length; i++) {
myCamera = myComp[i].activeCamera;
myCamera.depthOfField.setValue([1]);
}
}
myPalette.onResizing = myPalette.onRize = function () {this.layout.resize();}
} //if (myPalette != null )
return myPalette;
} //function buildUI (thisObject)