Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

Create artboard around group, unless there's a clipping path, then create the artboard around the clipping path

$
0
0

Hello again everyone.

 

I've been able to work out a bunch of this code from other people's questions, but i've hit a snag in my if/else clause structure.. I need to make an artboard around each top level groupItem on layer[0]. That part is cake.. unless there's a clipping mask. Visible bounds don't work when there's a clipping mask. So i built some for loops that cycle through the pathItems to search for the clipping mask and return the visibleBounds of said mask. However, i can't seem to work out how to structure the if clause in a way that will create the artboard around the clipping mask if there is one.

 

I'm successfully finding the visibleBounds of the mask and creating the appropriate artboard, but it's ALSO creating an artboard around the visible bounds of the entire group. How would i structure an if clause to determine whether an artboard was made around the clip path already and thus, not create a second artboard around the visible bounds of the whole groupItem? i imagine i'd need some kind of function to determine whether createdArtboardAroundClip = true and if so, skip this group..

 

Thanks all.

 

here's the code:

 

var aB = docRef.artboards;
var docLayers = docRef.layers;
var layer1 = docLayers[0];
var groupLevel1 = layer1.groupItems;

for (a = 0; a < groupLevel1.length; a++){    var groupLevel2 = groupLevel1[a].groupItems;    var vB = groupLevel1[a].visibleBounds       for (b = 0; b < groupLevel2.length; b++){        var paths = groupLevel2[b].pathItems;               for (c = 0; c < paths.length; c++){            if (paths[c].clipping == true){                var clipBounds = paths[c].visibleBounds;                aB.add(clipBounds);                break;                }            }        }    aB.add(vB);    }

Viewing all articles
Browse latest Browse all 12845

Trending Articles