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

Looking for a way to update smart objects from PSB via script

New Here ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

I've written several scripts to automate a lot of this image pipeline I'm working on.

The last problem to solve is this:
Setup:
Primary PSD -> Contains several layers that are smart object to a secondary PSB

Secondary PSB -> Has several groups, inside each group are other smart objects/layers

My current manual steps:
1. Secondary PSB -> Make 'next' group visible

2. Secodary PSB -> Save PSB (ctrl+s)

3. Photoshop updates smart objects

4. switch back to Primary PSD document

5. Export As PNG

6. Choose name {SecondaryPSB_GroupName.png}

repeat 1-6 several times

 

I have scripts that I can modify to accomodate most of 1, 5 and 6. I'm having trouble finding examples where the script saves the PSB as the same filename, and then I'm not sure of a solid approach to waiting for step 3 to complete, can sometimes take 40+ seconds

 

I tried something like this, but it is either silently failing (I'm pretty sure) and/or it just isn't updating the smart object.

 

 

function SaveCurrentDoc(destinationFolder, shouldClose){
    var psdOptions = new PhotoshopSaveOptions();
    psdOptions.embedColorProfile = true;
    psdOptions.alphaChannels = true;
    psdOptions.layers = true;
    psdOptions.spotColors = true;

    var doc = activeDocument;

    doc.saveAs(new File(destinationFolder + '/' + doc.name.split('.')[0] + '.psb'), psdOptions);
    if(shouldClose){
        doc.close(SaveOptions.DONOTSAVECHANGES);
    }
}

 

TOPICS
Actions and scripting , Windows

Views

304

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

LEGEND , Feb 16, 2022 Feb 16, 2022
with(activeDocument) save(), close()

Votes

Translate

Translate
Adobe
LEGEND ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

with(activeDocument) save(), close()

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 ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

@Kukurykus 

 

As a beginner, I'm curious, your code appears the equivalent of the "more standard":

 

 

app.activeDocument.close(SaveOptions.SAVECHANGES);

 

 

What benefit (if any) does using  with()  add to the process, or is this just your personal coding style?

 

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
LEGEND ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

Simply you don't have to repeat once used element. I'd ask why to use uneeded app. 'prefix'?

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 ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied


@Kukurykus wrote:

Simply you don't have to repeat once used element.


 

Ah, I think I see... So do you mean:

activeDocument.save();
activeDocument.close();

 vs.

with(activeDocument) save(), close()

 

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
LEGEND ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

Yes, and as the user was saving changes in open Smart Object you don't have to close with SaveOptions.SAVECHANGES, how ever when regular document is saved you don't need to use it as well. The 'with' is convinient for ex. when you want to use many saving options.

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 ,
Feb 17, 2022 Feb 17, 2022

Copy link to clipboard

Copied


@Kukurykus wrote:

 I'd ask why to use uneeded app. 'prefix'?


 

We all have our ideosyncracies! :]

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
LEGEND ,
Feb 17, 2022 Feb 17, 2022

Copy link to clipboard

Copied

LATEST

Be more individual than take others solutions as own.

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