Skip to main content
Participant
December 2, 2010
Question

Javascript to delete clipping mask

  • December 2, 2010
  • 1 reply
  • 1155 views

Hi all,

I have an Applescript that places a PDF into a document. When the file is placed, it's cropbox becomes a clipping mask, which I then need to delete.

So I have the following:

set themasterlayername to "Legend"

tell application "Adobe Illustrator"

tell current document

set clipList to every path item whose clipping is true

repeat with clipItem in clipList

set sel to name of (layer of clipItem)

if sel is themasterlayername then

delete clipItem

end if

end repeat

end tell

end tell

This seems to be the only way I can find path items that are clipping, by testing in a repeat loop whether they belong to the layer I have placed the PDF into.

However, when there are a lot of objects (say from a CAD file) on other layers, the script runs very slowly, as it has to test every object to see if 'clipping' is true

Would this be quicker in Javascript? Delete all clipping path items on a certain layer. Or is there another way to narrow down getting only items belonging to the specific layer? For some reason if I put in 'of layer themasterlayername', I get no objects.

Thanks for any help

Ian

This topic has been closed for replies.

1 reply

Muppet_Mark-QAl63s
Inspiring
December 2, 2010

This is NOT tested but could not…

tell application "Adobe Illustrator"

tell current document

delete (every path item of layer "Legend" whose clipping is true)

end tell

end tell

The 'whose filtering' and target layer should deal with the lot?

eamcpAuthor
Participant
December 3, 2010

Thanks for replying.

For some reason the 'of layer...' results in no items being found, despite there definitely being clipping objects on that layer, so unfortunately your example doesn't work.

Ian