FORUMS: list search recent posts

Scripting Photoshop: Duplicate active Layer

COW Forums : Adobe Photoshop

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Jan Kalosker
Scripting Photoshop: Duplicate active Layer
on May 1, 2013 at 7:15:55 am

Hey Folks!

I'm a real newbie to scripting photoshop. Also, I do not really know JavaScript. I work with ExtendScript Toolkit 2. I trie to learn JS but I have a problem I do not understand and I hope you will help me out.

I've written a dialogue, this works fine. But the effect don't starting when performing a click on 'OK'. The following is what I start with:


#target photoshop

function main() {
if ( app.documents.length <= 0) {
alert( uiAlertDocumentMustBeOpened );
return;
}

var newLayer = docRef.activeLayer.duplicate();
newLayer.selected = true;


When I start this script with the 'Play' Button in the top right corner of ESTK 2, no error occures, but nothing happened in Photoshop. I tried some other ways to get Photoshop duplicate the active Layer, but nothing worked.

Thanks for every answer.


Return to posts index

Jonathan Ziegler
Re: Scripting Photoshop: Duplicate active Layer
on May 1, 2013 at 4:14:26 pm

Did you already have a document open? Do you need to specify which doc you are performing the action on. I'm not real great with scripting. I'm getting CS6 on my machines in a couple days (finally!) so I'll try it out then.

Save early. Save often.

Jonathan Ziegler

http://www.electrictiger.com
520-360-8293


Return to posts index

Jan Kalosker
Re: Scripting Photoshop: Duplicate active Layer
on May 2, 2013 at 6:36:29 am

...that's the shit when you don't understand enough of the used language you use...

I found out, that the whole code I used before using the duplicate command is blocking the duplicate command. I deleted everything and made a variable:

var newdLayer = docRef.activeLayer.duplicate();

And then I was able, to just call this single variable to duplicate my selected Layer with success. The whole code left then is just the following:

#target photoshop

var docRef = activeDocument
var newdLayer = docRef.activeLayer.duplicate();

newdLayer;


It works perfectly.


What I just now don't know...is there anywhere a list of all photoshop commands in JavaScript? It's a pain to search hours after hours and days after days for just one single working command (like my duplicate command). At this moment, I have to find out how to select the just duplicated layer (without using its name or index id to stay more flexible, to get it worked even on documents with many layers) and how I apply the "reduce noise" filter. In ESTK 2 are some filters listed under Help->Adobe Photoshop Object Model...but not the filter I need...


Return to posts index


Jonathan Ziegler
Re: Scripting Photoshop: Duplicate active Layer
on May 2, 2013 at 6:29:23 pm

Dunno about JS because I suck at it, but I did find this: search for "Adobe Photoshop CS6 Scripting Guide" in your browser - its a PDF from Adobe with much useful info and code snips in AS, VBS and JS (depending on which you're comfortable with - sounds like JS is your thing). At 87 pages, it'll get you part way there. Has some neat info like using AS or VBS to do JS code.

The URL to directly download is absurdly long and it was easier to just paste the search criteria.

Right before I posted this, I found "Adobe Photoshop CS6 JavaScript Reference" as a PDF, too. They have 'em for AS, VBS, and JS. At 231 pages, I think it's what you'll need. Lemme know how it works. :)

Save early. Save often.

Jonathan Ziegler

http://www.electrictiger.com
520-360-8293


Return to posts index

Jan Kalosker
Re: Scripting Photoshop: Duplicate active Layer
on May 5, 2013 at 9:50:05 pm

Hey, thank you so much for your help. It helped me a lot...far too kind ;)


Return to posts index

Jonathan Ziegler
Re: Scripting Photoshop: Duplicate active Layer
on May 7, 2013 at 5:02:27 pm

Sweet! Glad to see it helped. I'm going to have a look at both the JS and AS versions. Getting CS6 this week. I think I actually like the download subscription thing - a little surprising they went this route, but with everything else going to downloads, its not that big a surprise.

Save early. Save often.

Jonathan Ziegler

http://www.electrictiger.com
520-360-8293


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]