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);
}
}
with(activeDocument) save(), close()
Copy link to clipboard
Copied
with(activeDocument) save(), close()
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Simply you don't have to repeat once used element. I'd ask why to use uneeded app. 'prefix'?
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()
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.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Be more individual than take others solutions as own.