2017-10-11 101 views
0

我需要知道如何使用ExtendScript更改After Effects 2017中文本圖層的顏色。我可以很簡單地更改文本本身,如下所示:如何使用ExtendScript更改After Effects 2017中文本圖層的顏色?

var comp=app.project.item(10); 
comp.layer(1).property('Source Text').setValue('My Text Here'); 

但是,如何設置該文本圖層的顏色?我會認爲這會很簡單,但是儘管有很多搜索,我還沒有找到任何明確解釋如何做到這一點的內容。

在此先感謝!

回答

0

After Effects CS6 Scripting guide的第182頁(Adobe公司給出的最新文檔)描述了TextDocument對象,它是文本圖層的Source Text屬性的數據類型。其中屬性是fillColor和strokeColor。

編輯它並不像看起來那麼簡單,你不能只分配值的源文本,你必須做出一個新的textDocument對象,使您的更改,然後分配的值源文本屬性添加到您創建的textDocument對象。

因此可以這樣設置:

var textProp = comp.layer(1).property('Source Text'); 
//make a new textDocument, copying the values of the current one 
var textDocument = textProp.value; 
// change any attributes of the textDocument here, e.g.: 
textDocument.fillColor = [R, G, B]; 
// write the textDocument over the existing one 
textProp.setValue(textDocument); 

R,G和B是浮點值,其中1.0⇒255中的8位的顏色。

你也可以看到,腳本指南在網上aeenhancers有它描述了構造一個錯字,它說newTextDocument它應該是new TextDocument

+0

我試過了。它不會改變圖層的顏色。例如,我用這個... var comp = app.project.item(17); comp.layer(1).property('Source Text')。fillColor = c; 其中c是[255,255,255] ...但文字不會變成白色。 –

+0

嘗試'[1,1,1]'該值是一個介於0和1之間的8位項目的浮點數,其中1映射到255 – stib

+0

dangit,忘記添加'.value'來獲取源文本的值。我已經修改了我的答案。 – stib