1 Reply Latest reply on Jan 28, 2016 4:52 AM by W_J_T

    How to select and delete every clipping masks in an Illustrator document using javascript?


      I'm making extend scripts for Adobe Illustrator CS6 (javascript) and I need to delete every clipping masks of a document.

      I already have a solution but it's not fast enough in big documents.

      Here is my code:

      var releaseClippingMasks = function(document)  {
        var pathItems = document.pathItems;
        log('Looking for clipping masks among ' + pathItems.length + ' elements');
        var n = 0;
        for(var p = pathItems.length - 1; p >= 0; p--) {
         if(p / 1000 == Math.round(p / 1000)) {
        log(p + ' remaining');
         if(pathItems[p].clipping) { // accessing to the element [p] of pathItems takes a lot of time
        log(n + ' deleted masks');

      There are not so many clipping masks in my documents, but a lot of pathItems (100000+), so iterating takes a very long time.

      Does anyone know a better way to select every clipping masks in a document by javascript? Any help would be very appreciated.