尝试填充已锁定透明像素的图层时,Photoshop会打开对话框

时间:2014-05-16 16:10:23

标签: photoshop-script

此脚本应将图层设置为锁定透明像素,然后使用颜色填充图层。它会这样做,除非它到达填充阶段,它会打开填充对话框,你必须打得好。

如果省略透明像素线,它将按预期运行,不会出现对话框。

有没有办法压制这个盒子?或者我做错了什么导致盒子打开?

#target photoshop
app.bringToFront();

doc = app.activeDocument;
doc.artLayers[0].isBackgroundLayer = false;
doc.artLayers[0].transparentPixelsLocked = true;
app.activeDocument.selection.fill(app.foregroundColor); 

1 个答案:

答案 0 :(得分:0)

解决方案是不锁定图层,而是使用AM代码填充尊重透明度的图层。

代码:

#target photoshop 

app.bringToFront(); 



doc = app.activeDocument; 

doc.artLayers[0].isBackgroundLayer = false; 

doc.activeLayer = doc.artLayers[0];

// =======================================================

var idFl = charIDToTypeID( "Fl  " );

    var desc18 = new ActionDescriptor();

    var idUsng = charIDToTypeID( "Usng" );

    var idFlCn = charIDToTypeID( "FlCn" );

    var idFrgC = charIDToTypeID( "FrgC" );

    desc18.putEnumerated( idUsng, idFlCn, idFrgC );

    var idOpct = charIDToTypeID( "Opct" );

    var idPrc = charIDToTypeID( "#Prc" );

    desc18.putUnitDouble( idOpct, idPrc, 100.000000 );

    var idMd = charIDToTypeID( "Md  " );

    var idBlnM = charIDToTypeID( "BlnM" );

    var idNrml = charIDToTypeID( "Nrml" );

    desc18.putEnumerated( idMd, idBlnM, idNrml );

    var idPrsT = charIDToTypeID( "PrsT" );

    desc18.putBoolean( idPrsT, true );

executeAction( idFl, desc18, DialogModes.NO );

来源:https://forums.adobe.com/thread/1475826