Skip to content

Instantly share code, notes, and snippets.

@hilukasz
Created June 1, 2012 02:27
Show Gist options
  • Save hilukasz/2848168 to your computer and use it in GitHub Desktop.
Save hilukasz/2848168 to your computer and use it in GitHub Desktop.
MySymbol.prototype.isIn = function(parentItem, runThis) {
//var parent = doc.pathItems[0];
var isTrue;
var parentVB = parentItem.visibleBounds;
var parentLeft = parentVB[0];
var parentTop = -parentVB[1]; //make negative number a positive illustrator measures everything down as negative
var parentRight = parentVB[2];
var parentBottom = -parentVB[3]; //make negative number a positive illustrator measures everything down as negative
print("parent is : " + parent.name);
print("child is : " + this.name);
if (isTrue){
runThis();
}
var child = this.visibleBounds;
pointIsIn(parentLeft, parentTop, parentBottom, parentRight, child);
function pointIsIn(parentLeft, parentTop, parentBottom, parentRight, child) {
print("parent bounds: "+left+" "+top+" "+right+" "+bottom);
print("cold bounds: "+ child[0] + child[1] + child[2] + child[3]);
if ( child[0] > parentLeft && childTop > parentTop && childRight < parentRight && childBottom > parentBottom) {
print("pass");
var isTrue = true;
return true;
} else {
print("fail");
var isTrue = false;
return false;
}
}
}
function runMe() {
print("success!");
}
var pageItems = doc.layers.getByName("parent").pageItems;
//for each "div" inside of the parent
for ( var i = 0; i < pageItems.length; i++ ) {
function alertName() { alert(itemName);}
var currentContainer = pageItems[i];
//var itemName = currentContainer.name;
// loop through all the symbols to check if it is in the div
for(var i = 0; i < doc.symbolItems.length; i++){
var currentSymbol = new MySymbol(i);
print(currentSymbol.mySymbolIndex);
print(" == end symbol == ");
currentSymbol.isIn(currentContainer, runMe);
}
}
print("\n ====== end containers ======== ");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment