0

How is it possible to create a clipping mask with a illustrator javascript script?

I tried this, but it doesnt work.

    var group = app.activeDocument.groupItems.add();

    var rect = layer.pathItems.rectangle( height, 0.0, width, height );
    rect.moveToBeginning( group );

    var ellipse = layer.pathItems.ellipse(ellipseLeft, ellipseTop, ellipseWidth, ellipseWidth);
    ellipse.clipping = true;
    ellipse.moveToBeginning( group );

What i need is a working code sample

0

You need to set the group to be clipped too (after adding your paths). I believe setting the ellipse to be the clipping mask is unnecessary if it is the last object you add (the top object in the group should become the clipping path if you don't specify).

var group = app.activeDocument.groupItems.add();

var rect = layer.pathItems.rectangle( height, 0.0, width, height );
rect.moveToBeginning( group );

var ellipse = layer.pathItems.ellipse(ellipseLeft, ellipseTop, ellipseWidth, ellipseWidth);
ellipse.clipping = true;
ellipse.moveToBeginning( group );

group.clipped = true; // <-- Add this after adding your paths to the group.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.