Skip to main content
Participant
November 2, 2009
Question

How to ungroup and releaseClipingMask?

  • November 2, 2009
  • 1 reply
  • 2201 views

Newbie question.

I have just embedded PDF docs in my AI doc (this part works).  Now I need to ungroup and then release cliping mask for each like I would do in the UI.

Embedding code:

for(i = app.activeDocument.placedItems.length - 1; i >= 0 ; i--) {
        app.activeDocument.placedItems.selected = true;
        app.activeDocument.placedItems.embed();
}

If I understand the docs correctly, after calling embed() the placedItem becomes a PageItem (or GroupItem)?  So I thought it would be something like this:

for (i = 0; i < app.activeDocument.pageItems.length; i++){
    app.activeDocument.pageItems.selected = true;
    app.activeDocument.pageItems.ungroup();
    app.activeDocument.pageItems.releaseClipingMask();
}

But I don't find any ungroup or releaseClipingMask methods anywhere in the docs.  How is this supposed to work?

-Dave

This topic has been closed for replies.

1 reply

Participating Frequently
November 2, 2009

The element becomes a RasterItem. PageItem is the base class of all the elements in an illustrator file ... that means that when referring to PageItem object you can talk about any type of object(RasterItem, PathItem, GroupItem etc.). Now moving an object outside it's clipping mask should be done with the clipping property of the PathItem object or move() method(which i§m not quite sure if it really works as i§m not sure what object.parent will return) *(can't test it atm so you'll excuse me if there are some mistakes)* :

basic idea of the script(1):

var v_doc = app.activeDocument;

var v_pObj = v_doc.pathItems;

//why we do the following: because normally a clipping mask can be only a PathItem, which has the property clipping which makes or does not make the object a clipping mask;

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

     v_pObj.clipping = false;

     v_pObj.remove();

}

you could also get around with this ... i think ... depends on what pageItem.parent returns(2):

var v_doc = app.activeDocument;

var v_pObj = v_doc.rasterItems;

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

     if(v_pObj.parent.typename != 'Layer') v_pObj.move(v_doc, ElementPlacement.PLACEATBEGINING);

  }

Message was edited by: sonicDream