Created
June 4, 2012 14:08
-
-
Save hilukasz/2868627 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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