Skip to content

Instantly share code, notes, and snippets.

@hilukasz
Created June 4, 2012 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hilukasz/2868627 to your computer and use it in GitHub Desktop.
Save hilukasz/2868627 to your computer and use it in GitHub Desktop.
#target illustrator
//start library
// function MyLayer() { } and function SubLayer() are constructor functions
function MyLayer(input) {
this.doc = app.activeDocument;
this.myLayerIndex = input || 0;
this.myLayerItem = this.hasLayerIndex() ? this.doc.layers[this.myLayerIndex] : false;
this.subLayers = this.myLayerItem.pageItems;
this.width = this.myLayerItem.width;
this.height = this.myLayerItem.height;
};
MyLayer.prototype.hasLayerIndex = function() {
return this.myLayerIndex <= this.doc.layers.length - 1;
};
function SubLayer(pageItem) {
this.subLayers = [];
this.pageItem = pageItem;
this.myLayerItem.pageItems.each(function(pageItem) {
this.subLayers.push(new MyPageItem(pageItem));
});
}
SubLayer.prototype.isIn = function() {
parentVB = parentItem.visibleBounds;
return this.left >= parentVB[0] &&
this.top >= parentVB[1] &&
this.right <= parentVB[2] &&
this.bottom >= parentVB[3];
};
//start script
var parentLayer = new MyLayer(0);
var parentSubLayers = parentLayer.subLayers;
var currentLayer = parentSubLayers[1];
var checkLayer = subLayersTwo.subLayers[0];
currentLayer.isIn(checkLayer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment