During processing the script alerts on clipping mask layers

Contributor ,
Sep 17, 2022 Sep 17, 2022

Copy link to clipboard

Copied

During processing the script alerts on clipping mask layers from selected layers and processes the clipper mask layer separately.

TOPICS
Actions and scripting , Windows

Views

343

Likes

Translate

Translate

Report

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

correct answers 3 Correct answers

Community Expert , Sep 18, 2022 Sep 18, 2022

@Nir Photo Art – I'm still not 100% certain of the desired outcome, however, try this:

 

#target photoshop

function main() {

    // Save the current dialog display settings
    var savedDisplayDialogs = app.displayDialogs;
    app.displayDialogs = DialogModes.NO;

    // Get the selected layers: courtesy of jazz-y
    var s2t = stringIDToTypeID;
    (r = new ActionReference()).putProperty(s2t('property'), p = s2t('targetLayersIDs'));
    r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('ta
...

Likes

Translate

Translate
Community Expert , Sep 19, 2022 Sep 19, 2022

@Nir Photo Art – I honestly don't understand 100% what you are after, this is probably as much to do with me as you!

 

Please try this function. In limited testing it appears to work, however, I haven't really tried to break it...

 

selectGroupedBaseLayer();

function selectGroupedBaseLayer() {
    // Stephen Marsh, v1.0 - 20th September 2022
    // Only works with a visible clipping mask base layer
    //alert('Clipping Mask = ' + activeDocument.activeLayer.grouped);
    if (activeDocument.acti
...

Likes

Translate

Translate
Community Expert , Sep 20, 2022 Sep 20, 2022

Update: This v2 code should work regardless of the visibility of the clipping group base layer:

 

selectGroupedBaseLayer();

function selectGroupedBaseLayer() {
    // Stephen Marsh, v2.0 - 20th September 2022
    // Works with a visible or invisible clipping mask base layer
    //alert('Clipping Mask = ' + activeDocument.activeLayer.grouped);
    for (i = 0; i < activeDocument.layers.length; i++) {
        if (activeDocument.activeLayer.grouped === true) {
            //alert("Grouped, move on.
...

Likes

Translate

Translate
Community Expert ,
Sep 17, 2022 Sep 17, 2022

Copy link to clipboard

Copied

I'm not sure what you are asking. The processing is determined by the visibility of layers and toggling masks and clipping paths on and off already. It just doesn't happen automatically based on selections, you have to do it manually by toggling the items in the layers palette.

 

Mylenium

Likes

Translate

Translate

Report

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
Community Expert ,
Sep 18, 2022 Sep 18, 2022

Copy link to clipboard

Copied

If you have selected certain layers for processing, then don't select clipping mask layers... So how are the layers selected?

 

Clipping masks at a minimum are based on a pair of layers, but it could also be more...

Likes

Translate

Translate

Report

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
Contributor ,
Sep 18, 2022 Sep 18, 2022

Copy link to clipboard

Copied

sorry sr i made a mistake in writing the topic i am correcting the topic

Likes

Translate

Translate

Report

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
Contributor ,
Sep 18, 2022 Sep 18, 2022

Copy link to clipboard

Copied

One would first select as many layers as one would like to process, but one would have to open the Layers panel to see if it is a clipping mask layer or not.

 

Looking at the layers panel in photoshop it shows that it is a clipping mask layer, but in the psd file it doesn't show that it is a clipping mask.

 

Likes

Translate

Translate

Report

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
Community Expert ,
Sep 18, 2022 Sep 18, 2022

Copy link to clipboard

Copied

Selecting layers would generally require the layers panel to be open and for one to decide which layers to select.

 

So, how exactly are you selecting the layers? Is this done via a script and not directly by the operator?

 

A script can check if an indented or "clipped" layer is part of a clipping group.

 

But what about the parent or base layer that creates the transparency for one or more layers placed above to be included in the clipping group?

 

Do you need to identify or ignore the base layer that the others are grouped against?

 

alert(activeDocument.activeLayer.grouped);

 

The above returns a true/false boolean which you can use in a try/catch or if/else statement to ignore a clipped layer.

Likes

Translate

Translate

Report

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
Contributor ,
Sep 18, 2022 Sep 18, 2022

Copy link to clipboard

Copied

Sir I don't know how to make script

If I knew how to write a script, I wouldn't have asked you to make a script for me

In the script I add the listener code and it does its own thing

Likes

Translate

Translate

Report

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
Community Expert ,
Sep 18, 2022 Sep 18, 2022

Copy link to clipboard

Copied

Can you illustrate what you want with a screenshot?

Likes

Translate

Translate

Report

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
Contributor ,
Sep 18, 2022 Sep 18, 2022

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

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
Contributor ,
Sep 18, 2022 Sep 18, 2022

Copy link to clipboard

Copied

Stephen_A_Marsh .  sr

 

It is possible that if a clipper mask is also selected during processing, the script will process at a lower level.

Likes

Translate

Translate

Report

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
Community Expert ,
Sep 18, 2022 Sep 18, 2022

Copy link to clipboard

Copied

@Nir Photo Art – I'm still not 100% certain of the desired outcome, however, try this:

 

#target photoshop

function main() {

    // Save the current dialog display settings
    var savedDisplayDialogs = app.displayDialogs;
    app.displayDialogs = DialogModes.NO;

    // Get the selected layers: courtesy of jazz-y
    var s2t = stringIDToTypeID;
    (r = new ActionReference()).putProperty(s2t('property'), p = s2t('targetLayersIDs'));
    r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
    var lrs = executeActionGet(r).getList(p),
        sel = new ActionReference();

    // Loop over the selected layers: courtesy of jazz-y
    for (var i = 0; i < lrs.count; i++) {
        sel.putIdentifier(s2t('layer'), p = lrs.getReference(i).getIdentifier(s2t('layerID')));
        (r = new ActionReference()).putIdentifier(s2t('layer'), p);
        (d = new ActionDescriptor()).putReference(s2t("target"), r);
        executeAction(s2t('select'), d, DialogModes.NO);

        // Do something
            if (activeDocument.activeLayer.grouped == false) {
                alert("Process the non-clipped layer");
            } else {
                alert("Ignore the clipped layer");
            }
        }
    // Finish the loop

    // Restore the dialogs
    app.displayDialogs = savedDisplayDialogs;
}

// Single history stage undo
activeDocument.suspendHistory("Undo script", "main()");

Likes

Translate

Translate

Report

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
Contributor ,
Sep 18, 2022 Sep 18, 2022

Copy link to clipboard

Copied

Yes sir the script works great but there is a problem if more than one layers are clipped?

The script can directly select the layer to which most of the layers are clippedJatin 00 10 copy 2.jpg

Likes

Translate

Translate

Report

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
Community Expert ,
Sep 19, 2022 Sep 19, 2022

Copy link to clipboard

Copied

@Nir Photo Art – Sorry, I don't know how to do that. Perhaps a more advanced scripter could step up...

Likes

Translate

Translate

Report

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
Contributor ,
Sep 19, 2022 Sep 19, 2022

Copy link to clipboard

Copied

No problem sir, you tried to make a script for me, thank you very much for that

The important thing is not that the script was not made, but the important thing is that you answered my question

You don't know me, you helped a stranger like me

If the script is not made today, it will be made in the future

those who try never give up

 

One who changes his destiny on the basis of intentions. God also changes the picture of the world with the help of him.

 

thank you very much

Likes

Translate

Translate

Report

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
Contributor ,
Sep 19, 2022 Sep 19, 2022

Copy link to clipboard

Copied

If you have time and you are free?

Sir I can give an example how to reach the bottom layer ??

In which layer all the layers have been clipped

 

Likes

Translate

Translate

Report

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
Community Expert ,
Sep 19, 2022 Sep 19, 2022

Copy link to clipboard

Copied


@Nir Photo Art wrote:

If you have time and you are free?

Sir I can give an example how to reach the bottom layer ??

In which layer all the layers have been clipped


 

Certainly, I'll be free a little later, but please show me what you have found...

Likes

Translate

Translate

Report

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
Contributor ,
Sep 19, 2022 Sep 19, 2022

Copy link to clipboard

Copied

This is just an example

I don't know how it can be done, this is just an idea in my mind

https://youtu.be/UcAYtccvjpE

 

Likes

Translate

Translate

Report

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
Community Expert ,
Sep 19, 2022 Sep 19, 2022

Copy link to clipboard

Copied

@Nir Photo Art 

 

The code that I posted previously loops over all selected layers.

 

If you just wish to select a single layer, check if it is the clipping group and move down to the "base/parent" layer and then stop, then that should be easier.

Likes

Translate

Translate

Report

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
Contributor ,
Sep 19, 2022 Sep 19, 2022

Copy link to clipboard

Copied

Manually is easy sir but I was wondering if it is possible in automation

No problem sir thank you very much

Likes

Translate

Translate

Report

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
Community Expert ,
Sep 19, 2022 Sep 19, 2022

Copy link to clipboard

Copied

@Nir Photo Art – I honestly don't understand 100% what you are after, this is probably as much to do with me as you!

 

Please try this function. In limited testing it appears to work, however, I haven't really tried to break it...

 

selectGroupedBaseLayer();

function selectGroupedBaseLayer() {
    // Stephen Marsh, v1.0 - 20th September 2022
    // Only works with a visible clipping mask base layer
    //alert('Clipping Mask = ' + activeDocument.activeLayer.grouped);
    if (activeDocument.activeLayer.grouped === true) {
        //alert("Grouped, move on...");
        toggleLayerVisibility(true);
        selectForwardORBackwardLayer(false, "backwardEnum");
        toggleLayerVisibility(true);
        //alert('Clipping Mask = ' + activeDocument.activeLayer.grouped);
        //activeDocument.activeLayer.visible = true;
    }
    // Helper Functions
    function toggleLayerVisibility(toggleOptionsPalette) {
        var s2t = function (s) {
            return app.stringIDToTypeID(s);
        };
        var descriptor = new ActionDescriptor();
        var list = new ActionList();
        var reference = new ActionReference();
        reference.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"));
        list.putReference(reference);
        descriptor.putList(s2t("null"), list);
        descriptor.putBoolean(s2t("toggleOptionsPalette"), toggleOptionsPalette);
        executeAction(s2t("show"), descriptor, DialogModes.NO);
    }
    function selectForwardORBackwardLayer(makeVisible, forwardORbackward) {
        var s2t = function (s) {
            return app.stringIDToTypeID(s);
        };
        var descriptor = new ActionDescriptor();
        var list = new ActionList();
        var reference = new ActionReference();
        // "forwardEnum" or "backwardEnum"
        reference.putEnumerated(s2t("layer"), s2t("ordinal"), s2t(forwardORbackward));
        descriptor.putReference(s2t("null"), reference);
        // true or false
        descriptor.putBoolean(s2t("makeVisible"), makeVisible);
        list.putInteger(15);
        descriptor.putList(s2t("layerID"), list);
        executeAction(s2t("select"), descriptor, DialogModes.NO);
    }
}

 

Edit: I tried to break it... The script fails if the base layer isn't visible.

 

Likes

Translate

Translate

Report

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
Contributor ,
Sep 19, 2022 Sep 19, 2022

Copy link to clipboard

Copied

Thank you thank you thank you very much script is very nice and works very great

The script works exactly as I thought

You are great, you are geniuses

Thank Thank Thank Thank Thank................

Likes

Translate

Translate

Report

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
Community Expert ,
Sep 19, 2022 Sep 19, 2022

Copy link to clipboard

Copied

Thank you, I was clutching at straws, glad it is what you wanted after all that!

Likes

Translate

Translate

Report

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
Contributor ,
Sep 19, 2022 Sep 19, 2022

Copy link to clipboard

Copied

100% working sir lots of thanks...................

Even in the word impossible there is the word possible, sir, nothing is impossible, everything is possible, never give up.

One who changes his destiny on the basis of intentions. God also changes the picture of the world with the help of him.

Likes

Translate

Translate

Report

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
Community Expert ,
Sep 20, 2022 Sep 20, 2022

Copy link to clipboard

Copied

You're welcome, 2 days ago I didn't know how to do that, it's a bit of a kludge/hack... I exploited what I generally consider to be a shortcoming!

Likes

Translate

Translate

Report

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
Contributor ,
Sep 20, 2022 Sep 20, 2022

Copy link to clipboard

Copied

ometimes it also happens that the work done in the wrong way works well

The work becomes complete and successful only if the purpose of your work is right

Then even if the way of working is wrong, success is achieved

 

Likes

Translate

Translate

Report

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