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

How to access smartobjects within for-loop?

Community Beginner ,
Apr 21, 2015 Apr 21, 2015

Copy link to clipboard

Copied

Hi everybody,

I am working on a script that that changes the color of all the layers in a psd-document called "Fill". This works fine. However, now I would like to expand the functionality and make it check through all my smart-objects and check whether they have any layers called "Fill". If yes, then change their color as well.

So far I could only find script-listener code which doesn't work for me. It always gives the same error. It's in German, but roughly translates to "General Photoshop error. This functionality might not be available in this version of Photoshop..."

I tested it in CS5 and the newest CC version, both with the same results.

Are there any other ways?

Here is the code I used:

function openSmart(layerNode) {   

    for (var i=0; i<layerNode.length; i++) {

        openSmart(layerNode.layerSets);

        for(var layerIndex=0; layerIndex < layerNode.artLayers.length; layerIndex++) {

            var layer=layerNode.artLayers[layerIndex];

            if (layer.kind == LayerKind.SMARTOBJECT) {

                layer.visible = 1;

                var idAction = stringIDToTypeID( "placedLayerEditContents" );

                var idDesc = new ActionDescriptor();

                executeAction(idAction, idDesc, DialogModes.NO);

            }

        }

    }

}

openSmart(app.activeDocument.layerSets);

TOPICS
Actions and scripting

Views

497

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 1 Correct answer

Enthusiast , Apr 21, 2015 Apr 21, 2015

The "This functionality might not be available in this version of Photoshop"-error is pretty common that is often caused by either having wrong doc active or wrong layer selected or otherwise trying to execute something that does not apply to that object at the moment (e.g. wrong layer type, locked layer). Like that action or then changing the fill might require layer to be selected.

Votes

Translate

Translate
Adobe
Enthusiast ,
Apr 21, 2015 Apr 21, 2015

Copy link to clipboard

Copied

The "This functionality might not be available in this version of Photoshop"-error is pretty common that is often caused by either having wrong doc active or wrong layer selected or otherwise trying to execute something that does not apply to that object at the moment (e.g. wrong layer type, locked layer). Like that action or then changing the fill might require layer to be selected.

Votes

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 Beginner ,
Apr 21, 2015 Apr 21, 2015

Copy link to clipboard

Copied

Oh, thank you so much. Now I get it... So I can just set the selected/active layer to the current layer in the loop, then it works.

Votes

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
Enthusiast ,
Apr 21, 2015 Apr 21, 2015

Copy link to clipboard

Copied

LATEST

That might be the issue. Like said, that error is pretty generic "you did something that happened to fail this time". Many functions/actions require the layer/document in question to be the active/selected so worth a try. 

Votes

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