Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

[Script] Moving LayerSet with Mask

New Here ,
Mar 19, 2020 Mar 19, 2020

Hello,

 

I wrote the photoshop scripting code that move specific layerset like below.

 - app.activeDocument.layerSets[0].translate(0, new UnitValue(20, 'px'));
 
It works to most layersets, but not applicable to the layerset with mask.
The above code only move the mask layer, not the whole layer set.
 
FYI, when I click the layer group in the photoshop with mouse, there are two different actions.
For the layer group without mask, the layer group is selected.
But, for the layer group with maks, the layer mask is selected. When I click the layer group again, the layer group is selected.
 
But I do no know how to select the layerset, not the layer mask in the script.
 
If there is any suggestion, please let me know.
Thanks,
 
Hojae

 

TOPICS
Actions and scripting
597
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Mentor ,
Mar 20, 2020 Mar 20, 2020
LATEST

 

moveLayerSetWithMask(app.activeDocument.layerSets[0], 0, new UnitValue(20, 'px'))

function moveLayerSetWithMask(lrSet, dH, dV) {
    var id = lrSet.id

    if (hasLayerUserMask(id)) {
        var linked = getUserMaskLinkedState(id)
        setUserMaskLinkedState(id, true)
        lrSet.translate(dH, dV)
        setUserMaskLinkedState(id, linked)
    } else {
        lrSet.translate(dH, dV)
    }

    function setUserMaskLinkedState(id, linked) {
        desc = new ActionDescriptor(),
        desc2 = new ActionDescriptor(),
        ref = new ActionReference()

        ref.putIdentifier(s2t("layer"), id)
        desc.putReference(s2t("null"), ref)
        desc2.putBoolean(s2t("userMaskLinked"), linked)
        desc.putObject(s2t("to"), s2t("layer"), desc2)
        executeAction(s2t("set"), desc, DialogModes.NO)
    }

    function getUserMaskLinkedState(id) {
        ref = new ActionReference()
        ref.putProperty(s2t("property"), s2t("userMaskLinked"))
        ref.putIdentifier(s2t("layer"), id)
        return executeActionGet(ref).getBoolean(s2t("userMaskLinked"))
    }

    function hasLayerUserMask(id) {
        ref = new ActionReference()
        ref.putProperty(s2t("property"), s2t("hasUserMask"))
        ref.putIdentifier(s2t("layer"), id)
        return executeActionGet(ref).getBoolean(s2t("hasUserMask"))
    }

    function s2t (s) { return app.stringIDToTypeID(s) }
}

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines