• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

88.5K

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

...

Votes

Translate

Translate
Adobe
Community Expert ,
Aug 20, 2013 Aug 20, 2013

Copy link to clipboard

Copied

ok, then the problem was the compound clipping mask, I didn't do enough testing but anyway glad to hear you found out what it was and a way around it.

...don't worry about the elegant/not elegant stuff, related comments are meant to add some humor to this "a little too serious" forum.

Votes

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

I figured. Just felt foolish... also, despite a generally good sense of

humor I have a hard time mixing analytical thinking and a humorous tone...

especially online.

Votes

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

Copy link to clipboard

Copied

A slightly cynical sense of humor is a prerequisite when scripting AI don't worry if you don't already have this then you will soon catch it…

Kind of like those measles parties of old…

Votes

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 ,
Sep 26, 2013 Sep 26, 2013

Copy link to clipboard

Copied

Mark,

I knew I was here for a reason... 😉

Votes

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 ,
Sep 26, 2013 Sep 26, 2013

Copy link to clipboard

Copied

Hey Antoys, (and Carlos & Mark)

I think I finally identified a good way to do this.

It turns out the ".locked" and ".hidden" boolean values will not return false if only the item's parent container(s) are hidden or locked.  For example, when you lock a group in Illustrator, all the items in that groupappear locked.  But in reality each item within the group is still technically unlocked.

In looking through the documentation, I ran across the ".editable" boolean value and it seems to do the job.  Whether an item or any of its parent containers is locked or hidden, it renders that item's editable value as false.

Try this iteration out and let me know if it does the trick for you.

Carlos & Mark, can you think of any drawbacks to testing whether the item is editable?

#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;

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

            container.pathItems.remove();

            clippingCount++;

        }

    }

};

alert (clippingCount+" Clipping Masks Removed")

Votes

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 ,
Sep 26, 2013 Sep 26, 2013

Copy link to clipboard

Copied

Hey,

Quick thought:

I've noticed this script can crash Illustrator if there are a lot of clipping masks or its a really large file already.

More than once I've run this (or another) script and had things crash only to realize I hadn't saved my document recently.

To that end, here are two extra lines of code that can really save your butt.

Add this to the beginning of just about any script and it'll automatically save all open documents before the rest of the script executes. Certainly possible it could be a pain if you're looking for a quick fix script, but I'd rather wait a few extra seconds for it to save than risk losing progress!

for (i = 0; i < app.documents.length; i++)

{if (app.documents.saved == false) { app.documents.save()}}

Votes

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 ,
Oct 06, 2013 Oct 06, 2013

Copy link to clipboard

Copied

thanks ken, gonna try this as soon as i get my hands on my laptop again. thanks

Votes

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

Copy link to clipboard

Copied

mask.jpg

i tested the script again and same results appear even if i lock or hide the object having clipping masks. thanks for the help

Votes

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

Copy link to clipboard

Copied

i still can't figure out why locked or not, no clipping mask are removed using the script. really need help.. thanks

Votes

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 ,
Jul 11, 2018 Jul 11, 2018

Copy link to clipboard

Copied

You are a genuis. Thanks a lot.

Votes

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 ,
Oct 15, 2015 Oct 15, 2015

Copy link to clipboard

Copied

Thank so much, that good cript

Votes

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 ,
Jan 15, 2016 Jan 15, 2016

Copy link to clipboard

Copied

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

Votes

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
Guide ,
Jan 17, 2016 Jan 17, 2016

Copy link to clipboard

Copied

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...

Votes

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 ,
Jan 18, 2016 Jan 18, 2016

Copy link to clipboard

Copied

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.

Votes

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
Guide ,
Jan 18, 2016 Jan 18, 2016

Copy link to clipboard

Copied

in above posts others, not you have stated that the clipping path is located at the top of all clipping groups.

this can be moved and is not always the top item...
I did not mention layers...

this matters!, if you just check the top 1 item in all groups to test if if clipping is true, you can save iterating through every pathItem, much faster, but it may not catch all clipping paths.

as for how many people find them selves being handed 200+ files that someone else has created, or has been exported for another software that are messy with far too many clipping paths, among other things... I think you would be surprised.

I write scripts to improve my workflow.

I can save in excess of 2 hours a day using these.
I remedy bad situations by changing my workflow, and quite often a good script is part of that.

Votes

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 ,
Jan 26, 2016 Jan 26, 2016

Copy link to clipboard

Copied

I do a bunch of scripting with Illustrator but I do it with vb.net.  I was looking for a way to dump clipping masks when I place an eps on a page and I wound up here.

For future reference, here's the VB.net code I wrote.   I've trimmed out a bunch of stuff that this routine does just to use as an example of opening a page, grabbing a piece of art, deleting the clipping mask and saving it back out.  You might ask why I do that and it's because I fill a page with a bunch of items, including text and sometimes I have to change the fill color of a placed eps and that can only be done without a clipping mask.

Anyway, maybe this will help someone else some day.  Of course you have to have object references to the interop.illustrator dll and the cpu target has to be set for 64bit.

Sub whatever()
    Dim illusapp As New Illustrator.Application
    Dim illusdoc As Illustrator.Document
    Dim artitem3 As Illustrator.PlacedItem
    Dim pathitem1 As Illustrator.PathItem
    Dim epssaveoptions1 As New Illustrator.EPSSaveOptions
    Dim docpresets As New Illustrator.DocumentPreset
    Dim currentlayer As Illustrator.Layer
    Dim pointswidth As Double
    Dim pointsheight As Double

    Dim x As Integer
    Dim y As Integer

    page_width = 2.25 'In inches
    page_height = 4

    pointswidth = page_width * 72
    pointsheight = page_height * 72

    docpresets.DocumentUnits = Illustrator.AiRulerUnits.aiUnitsPoints
    docpresets.Width = pointswidth
    docpresets.Height = pointsheight
    docpresets.DocumentTitle = "Working Document"
    illusdoc = illusapp.Documents.AddDocument(Illustrator.AiDocumentColorSpace.aiDocumentCMYKColor, docpresets)

    output_namev = "c:\test\12345678.EPS"

    currentlayer = illusdoc.ActiveLayer
    artitem3 = currentlayer.PlacedItems.Add

    Try
        artitem3.File = "c:\test\test.eps"
        artitem3.Embed()

'---------------------------This is what I got out of this thread...iterate through the pathitems and delete any clipping masks...

        For x = 1 To illusdoc.PathItems.Count - 1
            pathitem1 = illusdoc.PathItems.Item(x)
            If pathitem1.Clipping = True Then
                pathitem1.Delete()
            End If
       

Next

'----------------------------

    Catch
        MsgBox(Err.ToString)
        Exit Sub
    End Try

    If My.Computer.FileSystem.FileExists(output_namev) Then
        My.Computer.FileSystem.DeleteFile(output_namev)
    End If
    epssaveoptions1.CMYKPostScript = True
    epssaveoptions1.Compatibility = Illustrator.AiCompatibility.aiIllustrator11

    illusdoc.SaveAs(output_namev, epssaveoptions1)
    illusdoc.Close()
    illusapp = Nothing

End Sub

Votes

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 Expert ,
Jan 27, 2016 Jan 27, 2016

Copy link to clipboard

Copied

thanks for sharing!!

Votes

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 ,
Apr 01, 2016 Apr 01, 2016

Copy link to clipboard

Copied

As simple as this..

Captura de Tela 2016-04-01 às 04.21.17.png  

Votes

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
Guest
Oct 13, 2016 Oct 13, 2016

Copy link to clipboard

Copied

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

pathItem or

groupitem?

Votes

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 ,
Jan 19, 2018 Jan 19, 2018

Copy link to clipboard

Copied

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

Votes

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 ,
May 03, 2018 May 03, 2018

Copy link to clipboard

Copied

Thanks for sharing !

Votes

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 09, 2020 Jul 09, 2020

Copy link to clipboard

Copied

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.Screen Shot 2020-07-09 at 2.14.31 PM.jpg

Votes

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 Expert ,
Jul 09, 2020 Jul 09, 2020

Copy link to clipboard

Copied

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

Votes

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 Expert ,
Jul 09, 2020 Jul 09, 2020

Copy link to clipboard

Copied

@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

😉

 

Votes

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

Copy link to clipboard

Copied

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")

Votes

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