1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

今スク 全てのコンポジションの中にあるエフェクトにエクスプレッションを追加

Last updated at Posted at 2019-02-03

レイヤーのエフェクトにエクスプレッションを追加し忘れた・・・

今大量のコンプがあり、中には写真+コメントの素材が入っています。
その中のテキストレイヤーにエクスプレッションを追加し忘れました。
コンポジションが50個近くあるのでエクスプレッションで一括変更。

やりたい事

コンポジション内のテキストのレイヤースタイル(光彩)にエクスプレッションを追加。

今日のスクリプト

var selectItems = app.project.selection;

app.beginUndoGroup("undo");

for (var i = 0; i < selectItems.length; i++) {
    var myItem =  selectItems[i];//選択したオブジェクト
    var myComp = selectItems[i]; // 選択したオブジェクトの名前を取得
    for ( var j = 1 ; j < myComp.numLayers+1 ; j++){
        $.writeln(j)
        try{
            myComp.layer(j).property("ADBE Layer Styles").property("outerGlow/enabled").property("outerGlow/blur").expression='footage("common.json").sourceData.text.光彩.サイズ;'
        }catch(e){
        }
    }
}
app.endUndoGroup();

注意点

今回はコンポの中の全てのレイヤースタイルを対象にしているので、もし他のレイヤースタイル光彩がアクティブになっているとそれも変更されます。
今回はテキストレイヤーにしかレイヤースタイルは適用されていないので、とりあえず、他のレイヤーはtry{}catch(e){}でエラーを回避しています。

さらに追加で・・・

前回のものにさらに追加が出てきたのでそのスクリプトも。
今回はちゃんとテキストレイヤーか判定(instanceof TextLayer)させています。
内容はテキストレイヤーのフォントやサイズ、塗りを変えた後にドロップシャドウも追加しました。
んで、気付いたのが、コマンドでドロップシャドウを追加するのですが、コンポジションをビューワーに表示させないとエラーにでシャドウが追加できませんでした。
どういうことだろう。
もしかしたらセレクトしている状態にしないといけないかもしれません。
とりあえず、これでも大丈夫なのでこのまま張っておきます。

今日のスクリプト

var selectItems = app.project.selection;

var fonts =["HGPMinchoB","HGPMinchoE"]

app.beginUndoGroup("undo");

for (var i = 0; i < selectItems.length; i++) {
    var myItem =  selectItems[i];//選択したオブジェクト
    var myComp = selectItems[i]; // 選択したオブジェクトの名前を取得
    myComp.openInViewer()
    for ( var j = 1 ; j < myComp.numLayers+1 ; j++){
        if ( myComp.layer(j) instanceof TextLayer ){
            var textLayer =  myComp.layer(j);
            var td = textLayer.property("ADBE Text Properties").property("ADBE Text Document").value;
            td.fontSize = 85;
            td.font =fonts[1];
            td.fillColor = colorSetToRgb("ffffff")
            textLayer.property("ADBE Text Properties").property("ADBE Text Document").setValue(td);
            textLayer.selected = true;
            app.executeCommand(9000);//ドロップシャドウ追加
            textLayer.property("ADBE Layer Styles").property("dropShadow/enabled").property("dropShadow/distance").expression = 'footage("common.json").sourceData.text.ドロップシャドウ.距離;';
            textLayer.property("ADBE Layer Styles").property("dropShadow/enabled").property("dropShadow/chokeMatte").expression = 'footage("common.json").sourceData.text.ドロップシャドウ.スプレッド;';
            textLayer.property("ADBE Layer Styles").property("dropShadow/enabled").property("dropShadow/blur").expression = 'footage("common.json").sourceData.text.ドロップシャドウ.サイズ;';
        }        
    }
}
app.endUndoGroup();


function colorSetToRgb(set){
    var bigint = parseInt (set, 16);
    var r = (bigint >> 16) & 255;
    var g = (bigint >> 8) & 255;
    var b = bigint & 255;
    return [r/255,g/255,b/255];
}

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?