Skip to content

Instantly share code, notes, and snippets.

@peace098beat
Created August 23, 2014 09:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peace098beat/47132bd9dd80dafe8fe0 to your computer and use it in GitHub Desktop.
Save peace098beat/47132bd9dd80dafe8fe0 to your computer and use it in GitHub Desktop.
[AE Script]テキストを読み込み配置。
/********************************************************
---- Deproy_TextDocument ver.1.0 ----
テキストを読み込み配置。
アンカーポイントを中心に設定。
(おまけ)カメラの焦点を合わす
by fifi 2014/03/22
/********************************************************/
// Project Reset
app.project.close(CloseOptions.DO_NOT_SAVE_CHANGES)
app.newProject();
// Make a Composition
var comp1 = app.project.items.addComp("comp1", 720, 480, 1.0, 5, 30);
// Active Composition
comp1.openInViewer();
//tmp
var camera1 = comp1.layers.addCamera('Camera1',[0,0]);
// File Input
alert("読み込むテキストファイルを選択してください。")
filename = File.openDialog("Choose Test File");
fileObj = new File(filename);
// layObj = app.project.item(1).layers.addText();
// Smaple4
startX = 50;
startY = 100;
x = startX;
y = startY;
dx = 140;
dy = 50;
var cycle = 1;
var i=0;
// Make Text Layer in Comp1
if (fileObj.open("r")){
while(!fileObj.eof){
// for (var i=1; i<comp1.layers.numLayers; i++){
txt = fileObj.readln();
// layObj = app.project.activeItem.layers.addText(txt);
var tmpLay = comp1.layers.addText(txt);
// text setting
var txtProp = tmpLay.property("Source Text");
var txtDoc = txtProp.value;
txtDoc.fontSize = 12;
txtProp.setValue(txtDoc);
// アンカーポイントを、レイヤーの中心に設置
// anchorpoint setting for Center of LayerObj
tmpLay.text.moreOption.groupingAlignment.setValue([0, -50]);
tmpLay.position.setValue([x,y]);
x = startX;
y = y+dy;
// var Cx =[];Cy=[];Cz=[];
var Cxy = tmpLay.transform.position.value; //alert(Cxy);
var Cx = Cxy[0]; // tmpLay.transform.position(1).value;
var Cy = Cxy[1]; // tmpLay.transform.yPosition.value;
var Cz = Cxy[2]; //comp1.layer(i).transform.zPosition.value;
// alert(Cx);alert(Cy);alert(Cz);
camera1.property("ADBE Transform Group").property("ADBE Anchor Point").setValueAtTime(i*cycle, [Cx,Cy,Cz]);
camera1.property("ADBE Transform Group").property("ADBE Position").setValueAtTime(i*cycle, [Cx,Cy,-1000]);
camera1.property("カメラオプション").property("ADBE Camera Zoom").setValue(5000);
i+=cycle;
}
fileObj.close();
}
// // Param
// var cycle = 1;
// // Position Set for Text Layer
// for(var i=1; i<= app.project.item(1).numLayers; i++){
// // app.project.item(1).layer(i).position.setValue([x,y]);
// comp1.layer(i).position.setValue([x,y]);
// // comp1.layer(i).position.setValueAtTime(0.0,[startX, startY]);
// // comp1.layer(i).position.setValueAtTime(1.0,[x, y]);
// var Cx = comp1.layer(i).transform.xPosition.value;
// var Cy = comp1.layer(i).transform.yPosition.value;
// var Cz = 0; //comp1.layer(i).transform.zPosition.value;
// // camera1.property("ADBE Transform Group").property("ADBE Position").setValueAtTime(i*cycle, [Cx,Cy]);
// // camera1.property("ADBE Transform Group").property("ADBE Position").setValueAtTime(i*cycle, [Cx,Cy]);
// // camera1.property("ADBE Transform Group").property("ADBE Position").setValueAtTime(i*cycle, [Cx,Cy]);
// // app.project.item(1).property("ADBE Transform Group").property("ADBE Position").setValueAtTime(i*cycle, [Cx,Cy]);
// camera1.property("ADBE Transform Group").property("ADBE Anchor Point").setValueAtTime(i*cycle, [Cx,Cy,Cz]);
// camera1.property("ADBE Transform Group").property("ADBE Position").setValueAtTime(i*cycle, [Cx,Cy,-1000]);
// // camera1.property("ADBE Transform Group").property("ADBE Position").setValueAtTime(i*cycle, [x,y,-1000]);
// x = startX;
// y = y+dy;
// }
// // var p = app.project.item(1).property("ADBE Transform Group").property("ADBE Position");
// var camera1 = app.project.item("カメラ 1")
// var Cx = comp1.layer(i).position[0];
// var Cy = comp1.layer(i).position[1];
// camera1.property("ADBE Transform Group").property("ADBE Position").setValueAtTime(i*cycle, [Cx,Cy]);
// var Camera1 = comp.layers.addCamera('Camera1',[0,0]);
/*
テキストレイヤーのプロパティの設定
*/
// var myLay = comp1.layer(1);
// var textProp = myLay.property("Source Text"); //or myLay.txt;
// var textDocument = textProp.value;
// textDocument.resetCharStyle(); //文字パネルをモトの状態に戻す
// textDocument.font = "KaiTi"; //"MS Gothic"
// textDocument.fontSize = 10;
// textDocument.applyFill = true; //塗り色の指定を受けるか
// textDocument.fillColor = [1.0, 1.0, 1.0]; //テキストレイヤーの色
// textDocument.applyStroke = false; //文字の周りの囲みの色の有無:trueでアリ
// textDocument.strokeColor = [0,1,0]; //囲みの色指定
// textDocument.strokeWidth = 2; //囲み幅
// textDocument.tracking = 50; //字詰め幅の指定
// textDocument.justfication = ParagraphJustification.CENTER_JUSTIFY; //段落タブの段落指定。この場合テキストの中央揃え。
// textProp.setValue(textDocument); //上部値をプロパティに入れる。
/********************************************************
---- Deproy_TextDocument ver.2.0 ----
テキストを読み込み配置。
アンカーポイントを中心に設定。
by fifi 2014/03/22
/********************************************************/
// Project Reset
// app.project.close(CloseOptions.DO_NOT_SAVE_CHANGES)
// app.newProject();
// Make a Composition
var comp1 = app.project.items.addComp("comp1", 720, 480, 1.0, 15, 30);
// Active Composition
comp1.openInViewer();
// File Input
alert("読み込むテキストファイルを選択してください。")
filename = File.openDialog("Choose Test File");
fileObj = new File(filename);
// layObj = app.project.item(1).layers.addText();
// Smaple4
startX = 50;
startY = 100;
x = startX;
y = startY;
dx = 140;
dy = 50;
// Make Text Layer in Comp1
if (fileObj.open("r")){
while(!fileObj.eof){
txt = fileObj.readln();
var tmpLay = comp1.layers.addText(txt);
// text setting
var txtProp = tmpLay.property("Source Text");
var txtDoc = txtProp.value;
txtDoc.fontSize = 12;
txtProp.setValue(txtDoc);
// アンカーポイントを、レイヤーの中心に設置
tmpLay.text.moreOption.groupingAlignment.setValue([0, -50]);
tmpLay.position.setValue([x,y]);
x = startX;
y = y+dy;
// Random
// x = Math.random(0, 480);
// y = Math.random(0, 720);
x = Math.random()*720*4;
y = Math.random()*480*4;
}
fileObj.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment