Skip to main content
Known Participant
November 10, 2008
Answered

Remove clipping mask

  • November 10, 2008
  • 12 replies
  • 93248 views
I need to remove the clipping mask in illustrator file through programmatically(Visual Basic (or) Javascript). Kindly advice me.

Thanks,
Prabudass
This topic has been closed for replies.
Correct answer KennethWebb

I realize this is an old thread, but I ran across it while looking for a solution to removing multiple clipping masks scattered throughout a document.

If you need to remove all the clipping masks from a document, here is a pretty simple script that will check all the pageItems and remove any that are being used as a clipping mask.

Comment out the last line if you don't want to see how many paths were deleted.  Its not a necesarry feature, but I like to know how many objects get deleted when I run something like this.

#target Illustrator

// script.name = RemoveClippingMasks.jsx

// script.description = deletes all PageItems being used as clipping masks.

// script.parent = Kenneth Webb // 01/07/2013

// script.elegant = true?

var docRef = app.activeDocument;

var clippingCount = 0

clipScan()

//loops through all pageItems, removing those that are clipping masks

function clipScan () {

    for (i=docRef.pageItems.length-1;i>=0;i--) {

        if (docRef.pageItems.clipping == true){

            docRef.pageItems.remove();

            clippingCount++;

        }

    }

};

alert ("All "+clippingCount+" Clipping Masks Removed")


Cheers!

12 replies

CarlosCanto
Adobe Expert
September 25, 2020

the forums migrated to a new platform and all scripts got ruined. 

 

here's an updated version

#target Illustrator

// script.name = RemoveClippingMasks.jsx

// script.description = deletes all pathItems being used as clipping masks that are visible and unlocked.

// script.parent = Kenneth Webb // 09/26/2013

var docRef = app.activeDocument;

var clippingCount = 0

clipScan(docRef) // searches the whole document

//clipScan(docRef.activeLayer); // searches the active layer

function clipScan (container) {

    for (i=container.pathItems.length-1;i>=0;i--) {

var item = container.pathItems[i];

        if (item.clipping == true && item.editable == true){ //screens for locked or hidden items

            container.pathItems[i].remove();

            clippingCount++;

        }

    }

};

alert (clippingCount+" Clipping Masks Removed")
Participating Frequently
December 21, 2021

You rock, Carlos. Very useful script, thank you for updating it here.

pixxxelschubser
Adobe Expert
July 9, 2020

@AG2011b143 wrote: "Yet another Adobe screw up. Every update brings new woes."

 

Keep cool.

You know, Illustrator is not a PDF editor. Like Monika said.
😉

 

----------------------------------------------------------------------


The script written in 2013 has stopped working.


Hmmm.
However, this is not a problem of the original script or an update to a newer program version of the Adobe software.

 

The main problem is:
The switch to the new forum software from Jive to Khoros has unfortunately damaged some of the older good scripts.

 

Usually a counter "[i]" is missing in the script. Like here too.

Try the following version. I have inserted the (presumably) missing counters. Hope this is ok for Kenneth Webb, the author.

#target Illustrator

// script.name = RemoveClippingMasks.jsx
// script.description = deletes all PageItems being used as clipping masks.
// script.parent = Kenneth Webb // 01/07/2013
// script.elegant = true?

var docRef = app.activeDocument;
var clippingCount = 0;

clipScan()

//loops through all pageItems, removing those that are clipping masks
function clipScan () {
    for (i=docRef.pageItems.length-1;i>=0;i--) { 
        if (docRef.pageItems[i].clipping == true) {
            docRef.pageItems[i].remove();
            clippingCount++;
        }
    }
};

alert ("All "+clippingCount+" Clipping Masks Removed");

 

If that works for you

have fun

😉

 

Inspiring
July 9, 2020

This got me all excieted but then it didn't work - is there an update that will work with newer AI versions?

 

As a side note, unnessary clipping paths drive me INSANE - they can take 10-15 minutes to search out and delete and I simply do not have the time to waste doing this several times every day, so I end up finding other ways to print the job.

 

Yet another Adobe screw up. Every update brings new woes.

Monika Gause
Adobe Expert
July 9, 2020

Unnecessary clipping masks almost always are caused by importing (opening) a PDF that doesn't have an embedded AI file.

servicecom1
New Participant
May 3, 2018

Thanks for sharing !

New Participant
January 19, 2018

This is so great.  I can't thank you enough.  I wish I had found this years ago.

October 14, 2016

can you please specify from where u want to remove clipping mask?

pathItem or

groupitem?

rodrigo6
New Participant
April 1, 2016

As simple as this..

  

erinm15
New Participant
January 15, 2016

Easier than using a script:

1. Go into layers and select any <path> within any <Clipping Group>

2. Go to Select > Same > Fill & Stroke

3. Press delete

Qwertyfly___
Brainiac
January 18, 2016

do that when you have 200+ files to go through and your going to get bored real quick.

a script is the best course of action.

if you want to add an extra layer of robustness. it's worth noting that once created the clipping path can be moved anywhere in the group and still work.

it will NOT always be the top path...

erinm15
New Participant
January 18, 2016

Doesn't matter what layer the clipping path is so I'm not sure what you're getting at there.

If you have 200+ files, I suppose you'd be better with a script, however, I'm not sure how many of us would ever be in that situation. If so, I would suggest changing your workflow instead of using scripts to remedy a bad situation.

Ducvo
New Participant
October 16, 2015

Thank so much, that good cript

KennethWebbCorrect answer
Inspiring
January 7, 2013

I realize this is an old thread, but I ran across it while looking for a solution to removing multiple clipping masks scattered throughout a document.

If you need to remove all the clipping masks from a document, here is a pretty simple script that will check all the pageItems and remove any that are being used as a clipping mask.

Comment out the last line if you don't want to see how many paths were deleted.  Its not a necesarry feature, but I like to know how many objects get deleted when I run something like this.

#target Illustrator

// script.name = RemoveClippingMasks.jsx

// script.description = deletes all PageItems being used as clipping masks.

// script.parent = Kenneth Webb // 01/07/2013

// script.elegant = true?

var docRef = app.activeDocument;

var clippingCount = 0

clipScan()

//loops through all pageItems, removing those that are clipping masks

function clipScan () {

    for (i=docRef.pageItems.length-1;i>=0;i--) {

        if (docRef.pageItems.clipping == true){

            docRef.pageItems.remove();

            clippingCount++;

        }

    }

};

alert ("All "+clippingCount+" Clipping Masks Removed")


Cheers!

New Participant
March 11, 2013

Yes, that's it! Thank you very much, this will help me alot! You dear sir, have saved me a lot of hours!

For other less technical people (like myself) who would like to use it:

1. copy the script of kenneth,

2. paste it in notepad

3. press save as -> click 'textdocument *.txt* and select any file

4. now save as: RemoveClippingMasks.jsx

5. Open the file you would like to delete all clipping masks from, and press File-> scripts -> and open the RemoveClippingMasks.jsx-script you just saved in notepad

You're done!

Maybe there is a much easier way, but it worked for me!

Inspiring
March 11, 2013

Glad I could help!