Skip to main content
Inspiring
July 15, 2025
해결됨

How to check if a layer's filter mask is enabled or disabled?

  • July 15, 2025
  • 1 답변
  • 288 조회

How to check if a layer's filter mask is enabled or disabled? 

The following is the log of enabling filter mask in the script listener, which can be used as a reference

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

// =======================================================
var idhistoryStateChanged = stringIDToTypeID( "historyStateChanged" );
var desc4 = new ActionDescriptor();
var idDocI = charIDToTypeID( "DocI" );
desc4.putInteger( idDocI, 219 );
var idIdnt = charIDToTypeID( "Idnt" );
desc4.putInteger( idIdnt, 270 );
var idNm = charIDToTypeID( "Nm " );
desc4.putString( idNm, """Disable Filter Mask""" );
var idhasEnglish = stringIDToTypeID( "hasEnglish" );
desc4.putBoolean( idhasEnglish, true );
var idItmI = charIDToTypeID( "ItmI" );
desc4.putInteger( idItmI, 14 );
var idcommandID = stringIDToTypeID( "commandID" );
desc4.putInteger( idcommandID, 5081 );
executeAction( idhistoryStateChanged, desc4, DialogModes.NO );

// =======================================================
var idsetd = charIDToTypeID( "setd" );
var desc5 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref1.putEnumerated( idLyr, idOrdn, idTrgt );
desc5.putReference( idnull, ref1 );
var idT = charIDToTypeID( "T " );
var desc6 = new ActionDescriptor();
var idfilterMaskEnable = stringIDToTypeID( "filterMaskEnable" );
desc6.putBoolean( idfilterMaskEnable, false );
var idLyr = charIDToTypeID( "Lyr " );
desc5.putObject( idT, idLyr, desc6 );
executeAction( idsetd, desc5, DialogModes.NO );

// =======================================================
var idinvokeCommand = stringIDToTypeID( "invokeCommand" );
var desc7 = new ActionDescriptor();
var idcommandID = stringIDToTypeID( "commandID" );
desc7.putInteger( idcommandID, 3076 );
var idkcanDispatchWhileModal = stringIDToTypeID( "kcanDispatchWhileModal" );
desc7.putBoolean( idkcanDispatchWhileModal, true );
executeAction( idinvokeCommand, desc7, DialogModes.NO );

// =======================================================
var idhistoryStateChanged = stringIDToTypeID( "historyStateChanged" );
var desc8 = new ActionDescriptor();
var idDocI = charIDToTypeID( "DocI" );
desc8.putInteger( idDocI, 219 );
var idIdnt = charIDToTypeID( "Idnt" );
desc8.putInteger( idIdnt, 271 );
var idNm = charIDToTypeID( "Nm " );
desc8.putString( idNm, """Enable Filter Mask""" );
var idhasEnglish = stringIDToTypeID( "hasEnglish" );
desc8.putBoolean( idhasEnglish, true );
var idItmI = charIDToTypeID( "ItmI" );
desc8.putInteger( idItmI, 15 );
var idcommandID = stringIDToTypeID( "commandID" );
desc8.putInteger( idcommandID, 5081 );
executeAction( idhistoryStateChanged, desc8, DialogModes.NO );

// =======================================================
var idsetd = charIDToTypeID( "setd" );
var desc9 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref2 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref2.putEnumerated( idLyr, idOrdn, idTrgt );
desc9.putReference( idnull, ref2 );
var idT = charIDToTypeID( "T " );
var desc10 = new ActionDescriptor();
var idfilterMaskEnable = stringIDToTypeID( "filterMaskEnable" );
desc10.putBoolean( idfilterMaskEnable, true );
var idLyr = charIDToTypeID( "Lyr " );
desc9.putObject( idT, idLyr, desc10 );
executeAction( idsetd, desc9, DialogModes.NO );

최고의 답변: jazz-y
s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('smartObjectMore'));
r.putEnumerated(s2t('layer'), s2t('ordinal'), s2t('targetEnum'));
if (executeActionGet(r).hasKey(p)) {
    var so = executeActionGet(r).getObjectValue(p);
    if (so.hasKey(s2t('filterFX'))) alert(so.getObjectValue(s2t('filterFX')).getBoolean(s2t('enabled')))
}

1 답변

Stephen Marsh
Community Expert
Community Expert
July 15, 2025

There's this:

/*
https://community.adobe.com/t5/photoshop-ecosystem-discussions/view-layer-mask-status-via-scripting/td-p/13278583
by jazz-y
*/
#target photoshop
s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('userMaskEnabled'));
r.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"));
if (executeActionGet(r).hasKey(p)) alert (executeActionGet(r).getBoolean(p));
javaer작성자
Inspiring
July 15, 2025

check if a layer's filter mask is enabled or disabled, not layer mask

 

jazz-y답변
Legend
July 15, 2025
s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('smartObjectMore'));
r.putEnumerated(s2t('layer'), s2t('ordinal'), s2t('targetEnum'));
if (executeActionGet(r).hasKey(p)) {
    var so = executeActionGet(r).getObjectValue(p);
    if (so.hasKey(s2t('filterFX'))) alert(so.getObjectValue(s2t('filterFX')).getBoolean(s2t('enabled')))
}