2012-12-12 85 views
3

我在JS中編寫了一個Photoshop腳本,它將每個圖層文件夾和空間分隔出來,就像精靈圖表一樣。我已經想出了這一部分,但我試圖在運行腳本時刪除任何形式的人爲錯誤。現在,您需要準備好每個圖層文件夾的正確命名文件,並且還必須將圖層蒙版應用於所選內容。用於創建和應用圖層蒙版的Photoshop JS腳本

我想刪除用戶需要應用圖層蒙版。我可以選擇圖層,然後選擇我想要遮罩的部分,但我不知道如何應用或創建遮罩。

,我想它被應用於:

function maskIt(){ 
    if(currentFrameCount < (frameNumber-1)){ 
     currentFrameCount = currentFrameCount+1; 
     currentFrame = ("frame"+currentFrameCount); 
     activeDocument.layers[currentFrame].visable; 
     activeDocument.selection.selectAll(); 
     //createMask(); 
     maskComplete = false; 
    } else if (currentFrameCount == (frameNumber-1)){ 
     currentFrameCount = currentFrameCount+1; 
     currentFrame = ("frame"+currentFrameCount); 
     activeDocument.layers[currentFrame].visable; 
     activeDocument.selection.selectAll(); 
     //createMask(); 
     currentFrameCount = 0; 
     maskComplete = true; 
    } 
} 

回答

1

從scriptlistener收拾這兩個功能可以幫助你:

// FUNCTION MAKE MASK() 
function makeMask() 
{ 
    // ======================================================= 
    var id4556 = charIDToTypeID("setd"); 
    var desc983 = new ActionDescriptor(); 
    var id4557 = charIDToTypeID("null"); 
    var ref657 = new ActionReference(); 
    var id4558 = charIDToTypeID("Chnl"); 
    var id4559 = charIDToTypeID("fsel"); 
    ref657.putProperty(id4558, id4559); 
    desc983.putReference(id4557, ref657); 
    var id4560 = charIDToTypeID("T "); 
    var ref658 = new ActionReference(); 
    var id4561 = charIDToTypeID("Chnl"); 
    var id4562 = charIDToTypeID("Chnl"); 
    var id4563 = charIDToTypeID("Trsp"); 
    ref658.putEnumerated(id4561, id4562, id4563); 
    desc983.putReference(id4560, ref658); 
    executeAction(id4556, desc983, DialogModes.NO); 

    // ======================================================= 
    var id4564 = charIDToTypeID("Mk "); 
    var desc984 = new ActionDescriptor(); 
    var id4565 = charIDToTypeID("Nw "); 
    var id4566 = charIDToTypeID("Chnl"); 
    desc984.putClass(id4565, id4566); 
    var id4567 = charIDToTypeID("At "); 
    var ref659 = new ActionReference(); 
    var id4568 = charIDToTypeID("Chnl"); 
    var id4569 = charIDToTypeID("Chnl"); 
    var id4570 = charIDToTypeID("Msk "); 
    ref659.putEnumerated(id4568, id4569, id4570); 
    desc984.putReference(id4567, ref659); 
    var id4571 = charIDToTypeID("Usng"); 
    var id4572 = charIDToTypeID("UsrM"); 
    var id4573 = charIDToTypeID("RvlS"); 
    desc984.putEnumerated(id4571, id4572, id4573); 
    executeAction(id4564, desc984, DialogModes.NO); 
} 


// FUNCTION APPLY LAYER MASK() 
function applyLayerMask() 
{ 
    // ======================================================= 
    var id1949 = charIDToTypeID("Dlt "); 
    var desc398 = new ActionDescriptor(); 
    var id1950 = charIDToTypeID("null"); 
    var ref291 = new ActionReference(); 
    var id1951 = charIDToTypeID("Chnl"); 
    var id1952 = charIDToTypeID("Chnl"); 
    var id1953 = charIDToTypeID("Msk "); 
    ref291.putEnumerated(id1951, id1952, id1953); 
    desc398.putReference(id1950, ref291); 
    var id1954 = charIDToTypeID("Aply"); 
    desc398.putBoolean(id1954, true); 
    executeAction(id1949, desc398, DialogModes.NO); 
} 

如果你想排除用戶錯誤的人,你可能需要第三個功能,它將檢測一個圖層是否具有掩碼開啓(選擇該圖層,嘗試複製並粘貼圖層蒙版;如果它不粘貼 - 沒有圖層蒙版)

相關問題