Created
June 1, 2012 02:27
-
-
Save hilukasz/2848168 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
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; | |
} | |
} | |
} |
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
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