Skip to main content
Participant
April 13, 2024
Answered

Copy LayerSets via code.

  • April 13, 2024
  • 2 replies
  • 250 views

Hello,

 

I am 2 days old in the wold of photoshop scripting and I am coiming from a python background. 

I am looking to create a script that loads three transparent png files into a document. One "render", "Shadow" and "reflectioon"(on the floor).

 

The problem is photoshop creates a "2D bounding box" around the image since its transparent and aligns the centre of this bounding box with the centre of the canvas.  So this "Bouonding" breaks the position and loads everything at the center. 

I am looking to get an output that is something similar to "Load files into Stack" function which keeps everything where they are in the 2D cordinates thus the reflections an shadows appear to be lower then the actual render layer. I tried using LoadFilesIntoStack option via code but somehow was not able to get the python equivalant to work.

 

I tried looking at it from another way where I open each image(which Photoshop will open on a blank canvas with it being positioned correctly), create another layer named "base"(filled with solid color) then create a Group named "set_render"). Then move the "base" and "render" layer under this Group. 

 

So hierarchy will look like this:

set_render(Group)

~~~~render(transparent image)

~~~~base(artLayer with solid color)

 

Copy this group to my desired document and then delete "base" ArtLayer. Thus maintaining the 2D coordinates. Have to do this three times one for "Shadow" and another one for "Refelection" as well.

The problem with that is there seems to be no way to use Copy() function on Groups. Its only available on individual artLayers. Unless there is a way to copy and paste this and i completely missed it. I do see a duplicate() option but not copy().

 

Any ideas how to go about this? I am also doing everything under Python but any language is fine. need to see if its possible first then may be convert that to python.

 

Thanks in advance

 

This topic has been closed for replies.
Correct answer Deven36038945hjfr

So I managed to get the LayerSet Copied over. I used Duplicate() and added "Target_doc" as argument.

 

currentDoc = app.ActiveDocument.Layers["Layer_Name"]

currentDoc.Duplicate("Target_Doc")

 

2 replies

Deven36038945hjfrAuthorCorrect answer
Participant
April 13, 2024

So I managed to get the LayerSet Copied over. I used Duplicate() and added "Target_doc" as argument.

 

currentDoc = app.ActiveDocument.Layers["Layer_Name"]

currentDoc.Duplicate("Target_Doc")

 

Stephen Marsh
Community Expert
Community Expert
April 13, 2024

Can you provide a sample completed layered file, and the separate files to create the final doc?

 

Do you wish to manually select the files, or should a folder be processed in "sets of 3" based on alphabetical sorting of filenames etc?