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

Reordering effects in Effect Parade

Explorer ,
Sep 17, 2022 Sep 17, 2022

Copy link to clipboard

Copied

I'm working on a script that duplicates a layer many times and adds a "set matte effect" to the new layers. I'm also copying all the effects from the source layer and pasting them to the new layers using the executeCommand method. I would like to have the set matte to be the first effect so that dropshadows etc would work correctly. Even when I add the set matte in code first and then do the paste executeCommand, the set matte effect ends up being the last effect. Is there a fix for this? Or is there a way to reorder the effects in the Effect Parade? PropertyIndex doesn't help as it is read only. 

 

Thanks! 

 

TOPICS
Scripting

Views

375

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

Community Expert , Sep 17, 2022 Sep 17, 2022

If you have a variable pointed at your Set Matte effect, I think you can use:

myEffect.moveTo(1)

 

Votes

Translate

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

Copy link to clipboard

Copied

If you have a variable pointed at your Set Matte effect, I think you can use:

myEffect.moveTo(1)

 

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
Explorer ,
Sep 17, 2022 Sep 17, 2022

Copy link to clipboard

Copied

That works pefectly. Cheers! 

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

Copy link to clipboard

Copied

Actually I ran into a new problem. Is there any limitations where in code one can call the executeCommand? When I moved the copying into a dedicated function the executeCommand call began to crash. Is the executeCommand blocking code? When I had the paste command in other section in code the effects were pasted somehow also on shapelayers that did not even exist at that point in code.

 

    function copyLayerEffects(sourceLayer, targetLayer) {

        // is there anything to copy
         if( sourceLayer.property("ADBE Effect Parade").numProperties !== 0 ) {
        
            
            // select the effects
            for(var i = 1; i <= sourceLayer.property("ADBE Effect Parade").numProperties; i++){
                sourceLayer.property("ADBE Effect Parade").property(i).selected = true;
            }
            
            // copy command
            alert(app); // is not undefined
            alert(app.findMenuCommandId("Copy with Property Links")); // alerts code 10310
            app.executeCommand(app.findMenuCommandId("Copy with Property Links")); // crashes
            
            // remove effects from the new layer because they get duplicated when the source is cloned
            while(targetLayer.property("ADBE Effect Parade").numProperties !== 0){
                targetLayer.property("ADBE Effect Parade").property(1).remove();
            }

            // paste command
            app.executeCommand(app.findMenuCommandId("Paste"));

        }

    }

 

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

Copy link to clipboard

Copied

Because the commands in the Edit Menu like Copy and Paste are so context sensitive (depend heavily on what's currently selected and which panel is active) -- and often aren't even legal (when the command would be dimmed out in the menu), you need to make sure your code is setting everything up exactly as expected by the command. Frankly, I avoid using app.executeCommand() unless there is no other way to accomplish what I need to do.

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

Copy link to clipboard

Copied

LATEST

Ok, that makes sense. The focus must shift somewhere else and it causes the crash. I can understand why you'd avoid using it. Thanks again!

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