Skip navigation
Currently Being Moderated

JS that applies all clipping paths at once?

Jun 25, 2012 8:07 AM

Hello,

 

I found the thread that contains the Applescript for this, but would love to have a Javascript that works the same. Anyone have or know of one for ID CS5 that will apply all clipping paths for a group of objects at once?

 

Thanks in advance, as always

 

Andy

 
Replies
  • Currently Being Moderated
    Jun 25, 2012 8:35 AM   in reply to Andymc7

    Hmmm ... the reverse of http://indesignsecrets.com/forum/indesign-add-ons-scripts-scripting-an d-plug-ins/release-clipping-masks-on-all-selected-objects ?

     

    (Maybe all you need to change is my None to xxxx, where 'xxxx' is the proper command for 'do' )

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 25, 2012 10:24 AM   in reply to Andymc7

    It depends on what your images are. Check the possible values here: http://jongware.mit.edu/idcs5.5js_html/idcs5.5js/pe_ClippingPathType.h tml

     

    For Photoshop images, you can get a list of the names of all paths (see http://jongware.mit.edu/idcs5.5js_html/idcs5.5js/pc_ClippingPathSettin gs.html) and you can select one. Perhaps all you need is the first (and typically, the only) path?

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 26, 2012 6:58 AM   in reply to Andymc7

    So it's all Photoshop paths? Yes, it ought to work. Perhaps you also need to specify which path ... Try with this line added:

     

    app.selection[i].images[0].clippingPath.appliedPathName = app.selection[i].images[0].clippingPath.photoshopPathNames[0];

     

    inside the try { .. } catch block. This ought to set the clipping path to the very first one in the file.

     

    It's important to do operations such as these inside a try .. catch block, because this construction shields you from errors. Without the try .. catch, the script would issue an error for the very first image it encounters that has zero paths (and thus "the first", which is numbered #0, is not valid) and then stop with the error alert. Now it will still signal the error but the 'error handler' (the second curly-bracketed part) ensures it does nothing with that information, and so it will ignore the error and continue with the next image.

     

    And yes, a Javascript needs to be saved as ".jsx" to work. Otherwise InDesign doesn't recognize it as a valid script.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points