3

When I use an Illustrator script using visible bounds or selection size on clipped art, the script sees the original size of the clipped art as the groups's size instead of its visible (clipped) size. Lets say I have a 150mm x 200mm image and I am using a clipping mask to clip out a 100mm x 100mm part. So now I see a rectangle 100mm x 100mm, then add some other elements on it -- it does not get bigger than 100mm x 100mm. Then I want to work with this size not the, original image's size.

How to implement this in the script to work further with it? I am using Illustrator CS5.

  • 1
    Does checking "Use Preview Bounds' in the preferences alter things? – Scott Sep 27 '13 at 16:02
2

As long as the clipped art is vector (as opposed to a raster image), you could use Object > Expand appearance on it to actually delete the parts that are clipped away. Thus, the script will no longer see the original art and work properly.

| improve this answer | |
0

You need to get the geometric bounds from the actual clipping path item; it's the first path item in a clipping group.

| improve this answer | |
0

A clipping group is basically a GroupItem with clipped: true and one of the items inside that group will have clipping: true.

Have a look at this script:

function getVisibleBounds(item, geometric) {
    var bounds;

    // `clipped` is a property of a group
    if (item.typename = "GroupItem" && item.clipped) {
        var clippingItem;

        // look at all the items in the group to find the clipping item
        for (var i = 0; i < item.pageItems.length; i++) {

            // a child item will have `clipping` property set
            if (item.pageItems[i].clipping) {

                // found the clipping item!
                clippingItem = item.pageItems[i];
                break;

            // do the same thing for CompoundPathItems
            } else if (item.pageItems[i].typename == "CompoundPathItem") {
                if (item.pageItems[i].pathItems[0].clipping) {
                    clippingItem = item.pageItems[i];
                    break;
                }
            }
        }
        // store the clipping item's bounds
        bounds = geometric ? clippingItem.geometricBounds : clippingItem.visibleBounds;
    } else {

        // or just a normal item
        bounds = geometric ? item.geometricBounds : item.visibleBounds;
    }
    return bounds;
}
| improve this answer | |

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.