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

Select Layers in Smartobject sequentialy and save Mainfile each time

Explorer ,
Mar 14, 2017 Mar 14, 2017

Copy link to clipboard

Copied

Hello All

i am trying to find a solution for the following scenario:

  1. Master File contains a smart object which will be replaced with a action (Name of SO Layer is constant).
  2. The smart objects do have a different amount of layers (i.e. one SO has 10 layers, while another one has 17).
  3. Script executed within the Master File should make each layer in the SO visible, save, return to Master File and save this out to a file containing the name of the visible layer in the Smart Object.

i can do this with actions (except the naming) as long as the Smart Objects have the same amount of layers and the same names for the layers.

Hope my explanation does not sound to complicated. Basically the Smart Objects comtain designs to be placed on apparel (shirts, hoodies) in the Master File. Each placed design should then be saved as a jpg and png with the name of the design/layer in the SO.

thank you everyone for your time and help. I'm happy to give something in return

Have a good day.

Daniel

p.s. Using PS CC 2017 on Mac

TOPICS
Actions and scripting

Views

2.7K

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
Adobe
Community Expert ,
Mar 15, 2017 Mar 15, 2017

Copy link to clipboard

Copied

A Smart Object Layer content its object can be replace. The replacement object must be the sames Size  for the Smart object layers associated transform is not replaces. The replacement file can be layer of not it makes no difference for Photoshop renders pixels for the object and uses these as them layer content. These Pixels are locked and can not be change by Photoshop tools like the paint brush, eraser etc. They can only be acted on with smart filters and transform.  The  layers pixels are not changed only its composite view is changed when these Photoshop adjustments are applied. A smart object layer is a single layer its object may be layered the Smart Object layer is a single layer in a Photoshop document. There can be more than one smart object layers and Smart Object Layers cal also share a common object. It an easy way to create a Picture Package. You replace a single object and all the images are changed in the Picture package.

A script could open a smart object layer object and I would think if the Object was a Photoshop object process the work document added to documents.  However if the object is a RAW file ACR wouls oper the RAW temp file users would see  ACR UI. If the object is an AI File AI would be started ant the object would open in AI.

You would need to script this if objects will have different number of layers. Actions can not use logic to get the number of layers and process x number of layers.

JJMack

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 ,
Mar 15, 2017 Mar 15, 2017

Copy link to clipboard

Copied

Hello JJMack

thank you for your answer and your time. Unfortunately you probably misunderstood my question.

I am aware of replacing smart objects and the sizing of it's content, this is all working as it should.

The "only" thing i need is a script that allows me to make each layer in the SO visible one after another and export a .jpg file from the master file containing the SO each time. If possible, the saved .jpg should contain the name of the corresponding layer in the smart object.

if you could get me into the right direction with the scripting, that would be awesome.

thanks again and have a good evening.

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 ,
Mar 15, 2017 Mar 15, 2017

Copy link to clipboard

Copied

Did you read the second part of my append I wrote that if the Smart Object Layer's object is and Photoshop object like a bunch of layers or a layered PDF or layer Tiff your Script most likely could have Photoshop open the Smart Object Layer's object in Photoshop and your script could then process the work document opened by Photoshop. Create new document for each layer, save our a jpeg file in the fouler you want with a unique name the includes the master document name smart object layer name the work document's layer name and close this new document. When all layers in the opened work document have been processed you would the close the work document without saving. The Smart Object layer object would not be updated it would remains as it was before your script opened the object in Photoshop.

If the layers object is a RAW file or a placed AI file the object would open in ACR or Illustrator.

JJMack

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 ,
Mar 15, 2017 Mar 15, 2017

Copy link to clipboard

Copied

I think JJMack idea is good.

There is also File > Export > Layers to Files

This should export each layer into single file. I am not sure about layers dimensions.

Then you could replace smarobject content. One replacement for one layer.

It could have a better performance. Opening and closing smart objects is a bit slow.

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 ,
Mar 16, 2017 Mar 16, 2017

Copy link to clipboard

Copied

Hello JJMack

 

thank you again for your answers and sorry for my ignorance regarding the second part of your comment.

Unfortunately i don't exactly understand what you suggest in this part. My native language is not english, so there could be a misunderstanding

 

As far as i understood by now from your's and Jarda Bereza's answers:

 

  1. It's not possible to execute a script that toggles a smart object layers to visible one after another, as the script needs to know how many layers are inside the smart object.
  2. I could go with a workaround that saves each layer from the smart object to a file/folder and reload all these files one after another to my master psd and save each time.

 

While i see that point nr. 2. could be a solution, it would probably involve more work to create such a script as when doing it with actions (switching SO layers on/off by layer names) as i have it by now. By the way, my main psd and the smart objects do have the same dimensions and the designs in the smart object do have the correct size and position. So there is no transformation involved in the script or actions.

 

Please see the attached diagram of what i'm trying to do, maybe this helps to explain. And sorry for my lack of knowledge regarding scripting in PS, i'm a designer and did not use scripting before.

 

Thanks again everyone and have a great day.

 

PS-Script-Diagram.jpg

 

P.S. Found another thread where someone asked almost same question. Sadly with no response, but he described as follows :

 

Is it possible to do the scripts and actions like this:

 

1. Goes to Smart object.

2. Gets first layer name, makes first layer visible, updates smart object.

3. Gets needed group name from the main document.

4. 2.Name + 3.Name and Saves as JPG.

 

And found a thread where they talk about getting names from smart object layers, but the code presented goes way beyond my understanding

Maybe some of you understand if this would do the trick: Layer comps ID and name

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
Contributor ,
Mar 16, 2017 Mar 16, 2017

Copy link to clipboard

Copied

don't see any problems, and why would you need layer comps for that. simply open smart object each time, hide all layers, show first one, close, save png, open smart object, hide all layers, show second layer, close, save png and so on

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 ,
Mar 16, 2017 Mar 16, 2017

Copy link to clipboard

Copied

Thanks a lot for your answer Evgeny

To be honest, my knowledge of ps scripting is very limited not to say zero. So could i do the following:

  1. select and open smart object from main/working file
  2. turn first layer visible (hide all others)
  3. save smart object and return to main/working file
  4. Save png/jpg containing the name of the main/working file and append the name of the active/visible layer in the smart object.
  5. repeat this steps for all layers in the smart object
  6. Replace the smart object in the main/working file with another one (with a action) that has a different amount of layers
  7. start the cycling trough all the layers in the smart object again.

so, i have to look for these scripts and combine them ?:

  • cycles trough ALL layers in a file
  • get name of visible layer
  • save file with a name in the clipboard (or wherever ps stores the copied name)

Thanks again Evgeny!

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 ,
Mar 16, 2017 Mar 16, 2017

Copy link to clipboard

Copied

johny_roger wrote

 

As far as i understood by now from your's and Jarda Bereza's answers:

 

  1. It's not possible to execute a script that toggles a smart object layers to visible one after another, as the script needs to know how many layers are inside the smart object.
  2. I could go with a workaround that saves each layer from the smart object to a file/folder and reload all these files one after another to my master psd and save each time.

 

To be honest, my knowledge of ps scripting is very limited not to say zero. So could i do the following:

 

  1. select and open smart object from main/working file
  2. turn first layer visible (hide all others)
  3. save smart object and return to main/working file
  4. Save png/jpg containing the name of the main/working file and append the name of the active/visible layer in the smart object.
  5. repeat this steps for all layers in the smart object
  6. Replace the smart object in the main/working file with another one (with a action) that has a different amount of layers
  7. start the cycling trough all the layers in the smart object again.

 

so, i have to look for these scripts and combine them ?:

 

  • cycles trough ALL layers in a file
  • get name of visible layer
  • save file with a name in the clipboard (or wherever ps stores the copied name)

 

Thanks again Evgeny!

First you have the wrong concept of what a smart object layer is.

A smart object layer is a single Photoshop Layer. You can toggle its visibility off and on.  It is a single layer in your Photoshop active document. The layers object may have  layer within it. However you do not have any access to these layers in your Active document. But you can open the layer object using Photoshop. Photoshop will copy the layers object to a temp work file.  If the file is associated with Photoshop, Photoshop will open it.  There will be an additional document open in Photoshop and it will become Photoshop active document.  Your script is still in control of Photoshop and should be able to process all the layer in this work document.  You should be able to create a new document for a layer. The new document will become Photoshop active document which you can save as a jpeg file and close the new document your script created from a layer.. When you close that document Photoshop will switch back to the work document where you can do that process for the next layer.  When all layers been saved as jpeg files your script would close the work document. Photoshop would then switch back to your original document you opened the smart object layers object from. Since your script made no changes to the object document Photoshop would not update the layer object it will remain as it was.

JJMack

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 ,
Mar 16, 2017 Mar 16, 2017

Copy link to clipboard

Copied

Hello JJMack

i think we are not getting each others idea of what to do Here's a short screencast: Demo Screencast

1. The Smart Object i use in my main file is a .psd document holding a linked .ai file on each layer.

2. My main/working files are T-Shirts, Hoodies and so on.

3. I have to toggle these layers visibility in the smart objects to place the design/print onto the shirt in the main/working file.

4. Then i have to save the main/working file with each design.

5. The main/working file will be exchanged (from T-Shirt to Hoodie mockup) after all have been saved.

6. A new Smart Object will be loaded/placed with the same linked designs, but in different sizes and positions.

7. Same procedure will be repeated for various mockups.

As i said, i have this set up for a test file using actions. But as actions rely on layer names, i cant simply replace the smart object with the designs with another that has a different amount/count of layers.

Hope that makes sense now to understand why i have to do it that way and can't save the smart object layers only.

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 ,
Mar 16, 2017 Mar 16, 2017

Copy link to clipboard

Copied

hjohny_roger wrote

 

Hello JJMack

 

i think we are not getting each others idea of what to do Here's a short screencast: Demo Screencast

 

1. The Smart Object i use in my main file is a .psd document holding a linked .ai file on each layer.

The only Adobe Application I use is Photoshop. One Adobe product is all I can handle.  I know that Illustrator can also be scripted.

As I wrote if the temp work file is associated with Photoshop, Photoshop would open it.  If the object is a linked linked placed AI file. If Illustrator is installed on your system Illustrator would open your layered AI file. If Illustrator is not installed on your system and you have associated .AI file with Adobe Photoshop. Photoshop does not support .AI files but Photoshop can open them as a eps or pdf as a raster layer not a layered document. So if you have Illustrator installed on you system Photoshop would start Illustrator passing the work file. It would wait till you either update the object or not and close illustrator.  Your Photoshop Script would not have any access to your .at files layers Photoshop does not support .AI files.  Placed .ai file are vector smart object will scale well as a single layer. Not layers.

 

Supported file formats in Photoshop

 

Do not use .AI files if you need access to the object layers in Photoshop.

JJMack

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 ,
Mar 16, 2017 Mar 16, 2017

Copy link to clipboard

Copied

Hello JJMack

did you watch my screencast? I do not need to alter/edit the .ai files. This is why i placed and linked them in this smart object i'm using. I only access the smart object containing the .ai files and NOT the .ai files itself.

The actions do work, but it takes a long time to create them and they can't grab the name of the layer to use it for the saved files, this is why i'm trying to solve this with a script.

Thanks for your help 

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 ,
Mar 16, 2017 Mar 16, 2017

Copy link to clipboard

Copied

I took a quick look at your screen cast but feel there was no need to. If you do not need to get at your linked .ai files layers  a Script can get your document name its layer names there can be duplicate names layer names, names need not be unique.   Smart objects that have Photoshop objects the object can be opened in Photoshop and Photoshop can get at the object layers and layer names. Your script can access all open documents an their layer and ther manes.

JJMack

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 ,
Mar 16, 2017 Mar 16, 2017

Copy link to clipboard

Copied

Hello JJ Mack

Ok, i think i know now how the workflow should be. But there are still some open questions as i could not find any answers to these yet (searched in this Forum / PS-Script / Stackoverflow).

  1. Is it possible to select process the smart object like : Start with the first layer and make only this one visible - save the smart object - save the main file - select the next layer in the smart object and make only this visible - save ... and so on. But once the last/bottom layer has been processed, the script should stop and i should be able to continue with the next actions/steps.
  2. I did not find a script/solution to mimic "alt click" on the visibilty layer icon with a script. So i would not have to make all layer invisible first and then show only the selected layer again. Select next layer and make only this one visible.
  3. Is there an option in PS to use point nr.2 on a layerset? Make only the selected layer visible but leave everything outside this layerset untouched?

Phu, getting a bit closer but my head is full of questionmarks.

Thanks again and have a good evening (here it's late now).

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 ,
Mar 16, 2017 Mar 16, 2017

Copy link to clipboard

Copied

johny_roger wrote

 

Hello JJ Mack

 

Ok, i think i know now how the workflow should be. But there are still some open questions as i could not find any answers to these yet (searched in this Forum / PS-Script / Stackoverflow).

 

  1. Is it possible to select process the smart object like : Start with the first layer and make only this one visible - save the smart object - save the main file - select the next layer in the smart object and make only this visible - save ... and so on. But once the last/bottom layer has been processed, the script should stop and i should be able to continue with the next actions/steps.

 

Photoshop is not a file editor it a document editor. In a script you can access all open document and access these documents layers. When you open a smart object layers object there will be at least two open document in Photoshop. The smart object work document is a separate document. It is not part of what you call your main document.   You could copy a layer to  your main  document one way or an other you would need position the layer in that document layer stack perhaps on top above all other layers and  position it over you tee shirt. Save a jpeg then delete that top layer and switch back to the objects work docyment to process the next layer.

johny_roger wrote

  1. above.
  2. I did not find a script/solution to mimic "alt click" on the visibilty layer icon with a script. So i would not have to make all layer invisible first and then show only the selected layer again. Select next layer and make only this one visible.

You do that by change the layer object visibility you do it you do not minc "Alt+Click".  There would be no reason for you to mess with the object work document layer visibility.

 

 

  1. Above.
  2. Above.
  3. Is there an option in PS to use point nr.2 on a layerset? Make only the selected layer visible but leave everything outside this layerset untouched?

.

Have no idea of what you mean or have in mind.

 

You need a better understanding of how Photoshop works.

JJMack

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 ,
Mar 17, 2017 Mar 17, 2017

Copy link to clipboard

Copied

Hello JJMack

thanks again for your time and effort. I just still think we don't understand each other right

It seems like the main "issue" you see is the fact that i have 2 documents for which i call one Main/Work doc. and the other Smart Object. I do understand, that my Smart Object is in fact just another .psd file placed/embeded into my my Main/Work document.

So my scripts will have to work with 2 documents at a time and as far as i know this shouldn't be an issue as i can target the opened documents by their names.

Anyway, it seems we go forth and back here and i need to finish this as soon as possible unfortunately. So i think my best option will be to ask for someone with scripting skills to program this as a paid job. Is maybe anyone here interested in that or could lead me to a website where freelancers with ps scripting skills are available ?

Thanks again everyone, i'm sure it can be done somehow and i won't give up by now

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 ,
Mar 17, 2017 Mar 17, 2017

Copy link to clipboard

Copied

Yes you can process all open documents and create layers in them.  You would not be playing with layers visibility as such you would be creating a new visible layer in your main document the  images you want on your tee shirt.  IMO your going about this in a strange way.  I believe it would normally be done using a template file which is populated by some automated process like Photoshop's Data Driven Graphics or some custom Script or Action.  The Images to be populated would be external files not part of the "Main Document" hidden in a smart objects layer object where the object is a layered document with the images in layers with the visibility off so not rendered in the smart object layer pixels.

JJMack

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 ,
Mar 17, 2017 Mar 17, 2017

Copy link to clipboard

Copied

Hello

 

While it may sound all very complicated, it's not a big thing i want to do. I try to explain again and recorded another screencast showcasing why i do it this way with the linked designs in the embedded file.

 

  1. Having psd. mockup files with plain unprinted apparel (Shirts, Hoodies, Pants) called i.E. T-Shirt Mockup, Hoodie Mockup.
  2. Having a second .psd file holding the print/design to be placed onto the apparel called "Master Designs File"
  3. As the print needs a different position/sizing on a Hoodie as on the T-Shirt, i have a corresponding .psd called "Master Design File" for each Apparel Mockup.
  4. Each apparel Mockup loads it's corresponding print designs file as a embedded .psd (smart object) "over" the apparel.
  5. If i have to change the root .ai file, the design on one day, i can simply run my actions again and all the items will be created in one (long) step.

 

So, again. All i want to do with the script is, that it makes every print design layer (one after another) VISIBLE and create/save the Apparel (Shirt, Hoodie) with this visible design. Then select the next design layer, make only this visible and save again.

 

I'm doing this now with actions and have to target each print design layer by name, which takes a lot of time to create. So it would be awesome to have a script that simply goes from top of the layer stack to the bottom and by making one layer after the other visible and return to the main apparel mockup file saving the composition out. If it would even be possible to catch the names of each deign layer and use it for the saved filename, that would be awesome.

 

PLEASE, see this screencast to see how it works by now and why i do it with two files and not loading all design files into my mockup file.

SCREENCAST

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 ,
Mar 17, 2017 Mar 17, 2017

Copy link to clipboard

Copied

I believe I understand what you are trying to automate.  I also know your having a hard time automating the process you do via Photoshop UI. for it would be quite complex process.  That is why I feel you having a hard time.  It is why I posted that web site in your other thread.  To show you what other have done.  They have Many Template they can Place your design into.  It is a much less complex task to populate a template with an image.   Photoshop Data Driven graphics can do that.   A Photoshop script can also batch populate images into a template.  A script can easily place in an image and size and position the image for then template. Images for T-shirts would be png file with transparency.  The would be create with some canvas aspect ratio, size and resolution. The bottom layer of the source of png its PSD would be empty except for two pixels that are have a 1% opacity one pixel is the top left corner the other in the bottom right corner.  The will force the PGN file aspect ratio and size to be consistent. You would build tour transparent design ine layers above the base last ans save the PSD and PNG or just the PSD the can be paced as easily as a png

JJMack

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
Participant ,
Mar 21, 2017 Mar 21, 2017

Copy link to clipboard

Copied

LATEST

Did you find a solution that works for you, or are you still looking for some scripting assistance?

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
Participant ,
Mar 16, 2017 Mar 16, 2017

Copy link to clipboard

Copied

You can try using the "Unsmart Objects" script to sidestep the whole smartobject thing entirely... it may work or it may not be what you need exactly, but here's the rundown...

1. Go here and get the "Unsmart Objects" script: Magic scripts for Photoshop

2. Add that script to your scripts directory so it will show up in your File->Scripts menu... :

Windows: C:/Program files/Adobe/Photoshop CC [your version]/Presets/Scripts

Mac OS X: Applications/Photoshop CS3/Presets/Scripts  (I think?)

From there you should be able to record an action of "unsmarting" the smart object, which will get you all the layers inside at the scale you want. Then you can export all layers?

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 ,
Mar 16, 2017 Mar 16, 2017

Copy link to clipboard

Copied

Hello Max

thank you for your answer. I downloaded the script and i can "import" all the visible layers from the smart object.

The only downside is, that i had a distortion map on the smart object, which obviously does not get copied onto the newly created layers. Sure i could re-apply it to all layers, but this would kill my cpu and would probably take forever .

Anyways, if i would go this route:

1. is it possible to run now a script for the imported layers to toggle one after another visible/save and go to the next layer.

2. would the script be able to know, when the last layer from that group has been made visible and saved out?

3. I'd need then to replace the background/T-Shirt with a different color and run these steps again.

Maybe check also my short screencast to understand better what i'm after

Screencast

I know, i'm asking a lot of questions, but i thought as i had it working with actions, it would be easy to do the same with a script.

Thanks again to everyone for your help. It's really appreciated!

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 ,
Mar 16, 2017 Mar 16, 2017

Copy link to clipboard

Copied

johny_roger wrote

 

I know, i'm asking a lot of questions, but i thought as i had it working with actions, it would be easy to do the same with a script.

 

Thanks again to everyone for your help. It's really appreciated!

Anything an Action can do you can do in a script.  In fact an Action can be converted into script code. It will run slower than the Action and like the action everything is hard codes Photoshop steps. Step step step....

 

Script can use logic your Action also does not has access to your Smart layers object layers.  So it seems you do not need to get at them.

JJMack

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 ,
Mar 18, 2017 Mar 18, 2017

Copy link to clipboard

Copied

Sent you a PM.

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