Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Remove clipping mask

Community Beginner ,
Nov 10, 2008 Nov 10, 2008

Copy link to clipboard

Copied

I need to remove the clipping mask in illustrator file through programmatically(Visual Basic (or) Javascript). Kindly advice me.

Thanks,
Prabudass
TOPICS
Scripting

Views

83.1K

Likes

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

correct answers 1 Correct answer

Explorer , Jan 07, 2013 Jan 07, 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 ...

Likes

Translate

Translate
Adobe Community Professional ,
Nov 10, 2008 Nov 10, 2008

Copy link to clipboard

Copied

The clipping mask will be the first path item in a grouped item. Exactly how to identify it is not readily apparent.

Likes

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
Community Beginner ,
Feb 11, 2009 Feb 11, 2009

Copy link to clipboard

Copied

Look for a path item whose "clipping" property is set to true, and do:<br /><br /><pathItem>.clipping = false<br /><br />or just delete it...

Likes

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
Explorer ,
Jan 07, 2013 Jan 07, 2013

Copy link to clipboard

Copied

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!

Likes

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 ,
Mar 11, 2013 Mar 11, 2013

Copy link to clipboard

Copied

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!

Likes

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
Explorer ,
Mar 11, 2013 Mar 11, 2013

Copy link to clipboard

Copied

Glad I could help!

Likes

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
Participant ,
Aug 21, 2015 Aug 21, 2015

Copy link to clipboard

Copied

Thanks so much for teaching me how to utilize scripts!!!!!!!

Likes

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 ,
Aug 19, 2016 Aug 19, 2016

Copy link to clipboard

Copied

This shit worked like charm. I feel like a hacker now. lol

Thank you very much, guys!

Likes

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
Explorer ,
Jul 02, 2018 Jul 02, 2018

Copy link to clipboard

Copied

Wow what a great post many many thanks for sharing with us.

Likes

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
Community Beginner ,
Sep 24, 2020 Sep 24, 2020

Copy link to clipboard

Copied

Anybody else getting this error when trying this? Does anybody have a solution? ThanksScreenshot 2020-09-24 161920.png

Likes

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
Explorer ,
May 23, 2013 May 23, 2013

Copy link to clipboard

Copied

The script works fine. Nice.

Is it possible to do this not in the whole document, but only on a specific layer?

I tryed to modify the script, but it doesn't work.

Here is my try

#target Illustrator

 

var docRef = app.activeDocument;

clipScan()

function clipScan () {

    for (i=doc.layers['Passer'].pageItems.length-1;i>=0;i--) {

        if (doc.layers['Passer'].pageItems.clipping == true){

            doc.layers['Passer'].pageItems.remove();

           

        }

    }

};

Likes

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
Explorer ,
May 23, 2013 May 23, 2013

Copy link to clipboard

Copied

Hey Flexo-Baker,

I'll take some time this weekend to update this script with some extra functionality...

Might have it tonight if I can't sleep on my flight... but that's unforseeable at the moment.

Likes

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 ,
Aug 18, 2013 Aug 18, 2013

Copy link to clipboard

Copied

how do you delete clipping masks but not the ones that are locked or hidden?

Likes

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 ,
Aug 18, 2013 Aug 18, 2013

Copy link to clipboard

Copied

Would you not be better off just looping the groupItems collection…? Seems a bit wasteful to trawl everything when this only applies to groups and their top path item…

Likes

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
Explorer ,
Aug 18, 2013 Aug 18, 2013

Copy link to clipboard

Copied

Mark, you're partly right. A clipping mask is generated normally as the first pathItem in a group. When I revised this a few months back I update the search parameter having realized clipping mask objects can only be created from pathItems. Unfortunately shortly after, my laptop was stolen and I rather forgot about updating this thread. I seem to recall that if a clipping mask is ungrouped manually the pathItem used to mask the group still hangs around without a stroke or fill but with the clipping property still true. So, you could definitely narrow the search to all pathItems in groups and still have this be effective, but I choose to play it safe in case there are any odd exceptions and search all pathItems. Below you'll find an updated script... I can't really test it at the moment because I'm working from a smart phone, but if memory serves, this is how to disregard locked items. I added a third "if" param to check for visibility, but to be honest I don't recall if this is the proper way to go about it. Can someone test it?

Also, I never did get around to adding layer specificity. Anyone goin to take a crack at it? 🙂

#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 // 07/19/2013

// script.elegant = more true

var docRef = app.activeDocument;

var clippingCount = 0

clipScan()

function clipScan () {

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

var item = docRef.pathItems;

        if (item.clipping == true && item.locked == false && item.visible == true.){

            docRef.pathItems.remove();

            clippingCount++;

        }

    }

};

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

Likes

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 ,
Aug 18, 2013 Aug 18, 2013

Copy link to clipboard

Copied

sir, i have tried your script and it is not as far as my own but i guess the script we have does not work even on the clipping mask that are not locked.. maybe, just maybe it is because of the method. not so sure.. the script does not remove any clipping mask even if it is locked or not. i just need help on this.. i have this problem for about 2 weeks now. thanks in advance

Likes

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 Community Professional ,
Aug 18, 2013 Aug 18, 2013

Copy link to clipboard

Copied

here's a revision, I kind of ruined the original script, this one does not remove the clipping path, it merely "releases" the clipping mask just as if you do it manually in the UI. Like Mark said, clipping masks are groups and besides having one path acting as the "clip", they have a clipped property, so there's no need to check the paths, unless we do want to remove the clip.

the function works with the whole document, a layer, or a group

#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 // 07/19/2013

// script.elegant = more true

var docRef = app.activeDocument;

var clippingCount = 0

unclip(docRef); // unclips Clipping Masks in the whole document

//unclip(docRef.activeLayer); // unclips Clipping Masks in the active layer

function unclip (container) {

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

        var item = container.groupItems;

            if (item.clipped == true && item.locked == false && item.hidden == false){

                item.clipped = false;

                clippingCount++;

            }

    }

}

alert (clippingCount +" Clipping Mask(s) Released");

Likes

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 ,
Aug 18, 2013 Aug 18, 2013

Copy link to clipboard

Copied

when i try to run the script, it says "The top item in the group must be a path item to create a mask".

Likes

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 Community Professional ,
Aug 18, 2013 Aug 18, 2013

Copy link to clipboard

Copied

I'm not creating any clipping mask, can you post a sample file to play with?

Likes

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 ,
Aug 19, 2013 Aug 19, 2013

Copy link to clipboard

Copied

Carlos… this is something new…

//script.elegant = more true

I wasn't aware of an almost boolean… How does it work?

Likes

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 Community Professional ,
Aug 19, 2013 Aug 19, 2013

Copy link to clipboard

Copied

Something like relative virgin.

Likes

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 Community Professional ,
Aug 19, 2013 Aug 19, 2013

Copy link to clipboard

Copied

Larry G. Schneider wrote:

Something like relative virgin.

...or a little pregnant?

Likes

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 Community Professional ,
Aug 19, 2013 Aug 19, 2013

Copy link to clipboard

Copied

Close

Likes

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 Community Professional ,
Aug 19, 2013 Aug 19, 2013

Copy link to clipboard

Copied

hahaha, no idea Mark, it must be valid in Kenneth's DOM

by the way, does the script work in your system? I don't know what kind of error is what Antoys is reporting

Likes

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
Explorer ,
Aug 20, 2013 Aug 20, 2013

Copy link to clipboard

Copied

"almost boolean"... Sure, why not? I thought my first script was a pretty elegant way of solving that problem. (ie: simple implementation & uncomplicated code). Howerver in retrospect simple implementation and uncomplicated code that takes more iterations than necessary to execute and leaves out greater functionality shouldn't be called elegant.  Obviously I'm not qualified to make the statement whether my code is elegant or not, and it was a nod to that sentiment... though to be fair I did first list it is "true?".  Certainly not boolean in either case, but what the heck? "//script.elegant" seems pretty extraneous anyway (except to warn people when something is not elegant).

In other news, I get the same error message as Antoys. (working on a friend's computer)

Carlos, it looks like your script gets hung up on compound clipping paths, otherwise it runs fine. 

I'm guessing a compound clipping path is recognized as a compound path item instead of a path item.

When I ran my script on a sample with a compound clipping path mask, it removed two paths for one clipping mask...

I pulled in your method for specifying the container (thanks!), and revised ".visible == true" to ".hidden == false" and my script works again!

As a note, the reason I built this script was to actually remove the clipping paths.  It sometimes has to chug a bit (if its over 100+ clipping masks), but it generally gets the job done.

I work with a lot of pdfs generated from CAD software which tend to have a ridiculous number of masks present due to the export process (the document I'm testing the scripts on has 744).  Not only do these obscure artwork I need to access, I have found clipping masks within clipping masks... even when I can access the vector paths I need with the direct selection tool, I often have tens or hundreds of extraneous lines with no stroke or fill that clutter up my artboard.  Hence removing the paths...

In general, I can't think of a good reason to keep around a path that is only being used to frame a clipping mask.  In most cases when you want to unclip something my guess is you wouldn't want to deal with an extraneous path that no longer has a purpose being in the document.  That's just my take on the subject... whatever the case, here is a working script that removes all unlocked and visible clipping paths. (also, sorry about the "&" error in the last code... idk when that slipped in there)

#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 // 07/20/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;

        if (item.clipping == true && item.locked == false && item.hidden == false){

            container.pathItems.remove();

            clippingCount++;

        }

    }

};

alert (clippingCount+" Clipping Masks Removed")


Cheers!

Likes

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
    • 1
    • 2