Skip to content

Instantly share code, notes, and snippets.

@Hoikohroh
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hoikohroh/949439c8f960ef3c982d to your computer and use it in GitHub Desktop.
Save Hoikohroh/949439c8f960ef3c982d to your computer and use it in GitHub Desktop.
Adobe AfterEffects script (JSX):Z_interval
/*
Adobe AfterEffects Script (JSX)
Z_interval
v20150716
*/
////////////////////////////////variable declaration////////////////////////////////
var thisComp = app.project.activeItem;
var thisLayer = null;
var temp = null;
var w, txtbox,chkbox,btnOK,btnCancel;
var thisW,thisH,newCamera;
////////////////////////////////body////////////////////////////////
var dlg = new showDialog;
var result = dlg.show("100");
if ( result[0] !="" && (isNaN(result[0]) == false)){
zInterval(result[0]);
if (result[1]){
createCam();
};
};
////////////////////////////////functions////////////////////////////////
// 01:create dialog
function showDialog()
{
w = new Window("dialog","Button Test",[0,0,150,120]);
w.center();
txtbox = w.add("edittext",[10,10,140,40]);
chkbox = w.add("checkbox",[10,52,140,80],"Create Camera");
btnOK = w.add("button",[10,80,68,110],"OK",{name:'ok'});
btnCancel = w.add("button",[72,80,140,110],"cancel",{name:'cancel'});
txtbox.helpTip = "offset Z amount (default:100pixel)";
this.show = function(def)
{
txtbox.text = def;
if ( w.show() < 2){
return [txtbox.text,chkbox.value];
}else{
return "";
}
}
};
//02: offset layer
function zInterval(val)
{
app.beginUndoGroup("Z_Interval");
if(thisComp instanceof CompItem){
for( i = 1 ; i <= thisComp.layers.length ; i++){
thisLayer = thisComp.layers[i];
thisLayer.threeDLayer = true;
temp = thisLayer.Position.value;
temp[2] = val * (i - 1);
thisLayer.Position.setValue(temp);
};
}else {
alert('select composition');
};
app.endUndoGroup();
};
//03:create camera
function createCam()
{
app.beginUndoGroup("Create Camera");
thisW = thisComp.width /2 ;
thisH = thisComp.height /2 ;
newCamera = thisComp.layers.addCamera("camera", [thisW,thisH]);
newCamera.Position.setValue([thisW,thisH,newCamera.Position.value[2]]);
app.endUndoGroup();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment