How can I select my top path and turn off clipping?

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

bretlinford

How can I select my top path and turn off clipping?

Post by bretlinford »

How can I select my top path and turn off clipping with javascript? Some of the top layers are named differently so I can't say "path 1". Thanks!

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Mike Hale

How can I select my top path and turn off clipping?

Post by Mike Hale »

Selecting the top path regardless of name is easy, but that may not be the clipping path. The only way I know to turn off a clipping mask in Photoshop is to delete the mask. This finds the clippingPath, makes a copy in case it is needed to reapply the clipping, then deletes the path.
Code: Select allvar clippingPathIndex = hasClippingPathIndex();
   if(clippingPathIndex !=-1){
      var clippingPathItem = app.activeDocument.pathItems[clippingPathIndex];
      clippingPathItem.duplicate();
      clippingPathItem.remove();
   }
function hasClippingPathIndex(){// returns -1 if no clipping path   
   var ref = new ActionReference();
   ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
   var desc = executeActionGet(ref);
   return desc.getObjectValue(stringIDToTypeID('clippingPathInfo')).getInteger(stringIDToTypeID('clippingPathIndex'));
};
if(hasClippingPathIndex()==-1) alert('clippingMask removed');
And if you know of way manually to release a clipping path without removing the path, please let me know.

EDIT: now that I think about it the layer name shouldn't matter for clippingPaths. If you meant clipping mask or clipping group then to release the top layer you could do..
Code: Select allactiveDocument.artLayers[0].grouped = false;