Highlighted

Remove clipping mask

Community Beginner ,
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

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!

Topics

Scripting

Views

80.4K

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

Remove clipping mask

Community Beginner ,
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

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!

Topics

Scripting

Views

80.4K

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
Nov 10, 2008 0
Adobe Community Professional ,
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
Reply
Loading...
Nov 10, 2008 0
Community Beginner ,
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
Reply
Loading...
Feb 11, 2009 0
Explorer ,
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
Reply
Loading...
Jan 07, 2013 14
New Here ,
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
Reply
Loading...
Mar 11, 2013 10
Explorer ,
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
Reply
Loading...
Mar 11, 2013 0
Participant ,
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
Reply
Loading...
Aug 21, 2015 0
New Here ,
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
Reply
Loading...
Aug 19, 2016 0
Explorer ,
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
Reply
Loading...
Jul 02, 2018 0
Community Beginner ,
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
Reply
Loading...
Sep 24, 2020 0
Explorer ,
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
Reply
Loading...
May 23, 2013 1
Explorer ,
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
Reply
Loading...
May 23, 2013 0
New Here ,
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
Reply
Loading...
Aug 18, 2013 0
Guru ,
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
Reply
Loading...
Aug 18, 2013 0
Explorer ,
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
Reply
Loading...
Aug 18, 2013 0
New Here ,
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
Reply
Loading...
Aug 18, 2013 0
Adobe Community Professional ,
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
Reply
Loading...
Aug 18, 2013 0
New Here ,
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
Reply
Loading...
Aug 18, 2013 0
Adobe Community Professional ,
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
Reply
Loading...
Aug 18, 2013 0
New Here ,
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

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
Reply
Loading...
Aug 19, 2013 0
Guru ,
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
Reply
Loading...
Aug 19, 2013 0
Adobe Community Professional ,
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
Reply
Loading...
Aug 19, 2013 0
Adobe Community Professional ,
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
Reply
Loading...
Aug 19, 2013 0
Adobe Community Professional ,
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
Reply
Loading...
Aug 19, 2013 0
Adobe Community Professional ,
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
Reply
Loading...
Aug 19, 2013 0
Explorer ,
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
Reply
Loading...
Aug 20, 2013 0
Adobe Community Professional ,
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.

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
Reply
Loading...
Aug 20, 2013 0
Explorer ,
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.

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
Reply
Loading...
Aug 20, 2013 0
Guru ,
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…

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
Reply
Loading...
Aug 20, 2013 0
New Here ,
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

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
Reply
Loading...
Aug 21, 2013 0
Explorer ,
Sep 26, 2013

Copy link to clipboard

Copied

Mark,

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

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
Reply
Loading...
Sep 26, 2013 0
Explorer ,
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")

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
Reply
Loading...
Sep 26, 2013 1
Explorer ,
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()}}

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
Reply
Loading...
Sep 26, 2013 0
New Here ,
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

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
Reply
Loading...
Oct 06, 2013 0
New Here ,
Jul 11, 2018

Copy link to clipboard

Copied

You are a genuis. Thanks a lot.

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
Reply
Loading...
Jul 11, 2018 0
New Here ,
Oct 15, 2015

Copy link to clipboard

Copied

Thank so much, that good cript

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
Reply
Loading...
Oct 15, 2015 0
New Here ,
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

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
Reply
Loading...
Jan 15, 2016 0
Guide ,
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...

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
Reply
Loading...
Jan 17, 2016 0
New Here ,
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.

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
Reply
Loading...
Jan 18, 2016 0
Guide ,
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.

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
Reply
Loading...
Jan 18, 2016 0
Community Beginner ,
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

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
Reply
Loading...
Jan 26, 2016 1
Adobe Community Professional ,
Jan 27, 2016

Copy link to clipboard

Copied

thanks for sharing!!

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
Reply
Loading...
Jan 27, 2016 0