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

Help creating script to select first path and make into clipping path

New Here ,
Jul 04, 2014 Jul 04, 2014

Copy link to clipboard

Copied

Hi there,

I've been making actions for a while, but I have a need for something more advanced than what actions can achieve.

Basically I have a lot of images with multiple paths. What i'd like to do is have a script that selects the top path and converts it to a clipping path. Could someone point me in the right direction? I've found a few muddled examples by googling, but some either don't work or I can't make any sense out of. I'm hoping to add this script as part of an action so I don't want it to ask for a folder location, just to affect the document that is currently open.


Any help would be greatly appreciated and maybe I can learn some JS along the way!

Thanks

Jason

TOPICS
Actions and scripting

Views

382

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
Guru ,
Jul 04, 2014 Jul 04, 2014

Copy link to clipboard

Copied

This problem was my first need for a

PS script. If I recall correctly actions

record the name and not index.

When working with supplied images

from all over the place...

You will need script to do this part.

Sent from my iPhone

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
New Here ,
Jul 04, 2014 Jul 04, 2014

Copy link to clipboard

Copied

Hi Mark,

Yes that's exactly the case. Because I'm working with a variety of images the paths aren't named the same across different documents, so I'll need to select the index of the path to ensure I select the first path (i'm assuming it will be 0) but having little JS knowledge i'm really struggling.

Thanks

Jason

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
Guru ,
Jul 04, 2014 Jul 04, 2014

Copy link to clipboard

Copied

LATEST

#target photoshop

processPaths();

// Use clipping path else use path 1 even if its a work path

function processPaths() {

  var i, count = app.activeDocument.pathItems.length;

  if ( count >= 2 ) {

  for ( i = 0; i < count; i++) {

  

  if ( app.activeDocument.pathItems.kind == PathKind.CLIPPINGPATH ) {

  app.activeDocument.pathItems.makeClippingPath(0.5);

  };

  };

  };

  if ( count == 1 ) {

  if ( app.activeDocument.pathItems[0].kind == PathKind.WORKPATH ) {

  app.activeDocument.pathItems[0].name = "Clipping Path"

  };

  app.activeDocument.pathItems[0].makeClippingPath(0.5);

  };

};

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