2017-06-17 82 views

回答

0

你需要一個模式ID預先定義的模式選擇 - 做最簡單的方法是使用scriptListener並通過快速測試填充並檢查偵聽器代碼。這裏有一個例子:

var myPattern = "d5706459-5277-11e7-aad4-ff82069d78d5"; 
fill_with_pattern(myPattern) 

function fill_with_pattern(patternID) 
{ 
    var idFl = charIDToTypeID("Fl "); 
    var desc1283 = new ActionDescriptor(); 
    var idUsng = charIDToTypeID("Usng"); 
    var idFlCn = charIDToTypeID("FlCn"); 
    var idPtrn = charIDToTypeID("Ptrn"); 
    desc1283.putEnumerated(idUsng, idFlCn, idPtrn); 
    var idPtrn = charIDToTypeID("Ptrn"); 
    var desc1284 = new ActionDescriptor(); 
    var idNm = charIDToTypeID("Nm "); 
    desc1284.putString(idNm, """40x40"""); // id name 
    var idIdnt = charIDToTypeID("Idnt"); 
    desc1284.putString(idIdnt, patternID); 
    var idPtrn = charIDToTypeID("Ptrn"); 
    desc1283.putObject(idPtrn, idPtrn, desc1284); 
    var idOpct = charIDToTypeID("Opct"); 
    var idPrc = charIDToTypeID("#Prc"); 
    desc1283.putUnitDouble(idOpct, idPrc, 100.000000); //opacity 
    var idMd = charIDToTypeID("Md "); 
    var idBlnM = charIDToTypeID("BlnM"); 
    var idNrml = charIDToTypeID("Nrml"); 
    desc1283.putEnumerated(idMd, idBlnM, idNrml); 
    executeAction(idFl, desc1283, DialogModes.NO); 
} 

我想你可以通過名字來稱呼的模式,而不是它的ID - 但我沒有設法做成功。如果您嘗試使用預先存在的模式,如Bubbles,您將獲得如下代碼:

desc1297.putString(idNm, """$$$/Presets/Patterns/Patterns_pat/Bubbles=Bubbles"""); 
var idIdnt = charIDToTypeID("Idnt"); 
desc1297.putString(idIdnt, """b7334da0-122f-11d4-8bb5-e27e45023b5f"""); 
相關問題