I have been working on a script to place a psd file onto only one visible layer (document has multiple hidden layers).
This java code has worked so far:
var doc = app.activeDocument;
var onFile = File("C:/Users/Desktop/Desktop/ExportedArtboard-01.psd");
var mydoc = doc.placedItems.add();
mydoc.file = onFile;
mydoc.embed();
however this works with only the top layer visible (eye turned on in Ai). if top most layer isn't visible i get "target layer cannot be modified" error.
I've searched a lot in the forums and cant seem to figure this last code out if some can please help me make the code import the psd file to a layer that is currently visible (closests to top layer) would be great.
For instance say i have 1,2,3 layers. layer 1 (top most) and 3 (bottom most) would be hidden, layer 2 (middle layer) would be visible and then running the script would place the psd file on to layer 2.
Thank you!!!