Skip to content

Instantly share code, notes, and snippets.

@hilukasz
Created May 24, 2012 21:46
Show Gist options
  • Save hilukasz/2784422 to your computer and use it in GitHub Desktop.
Save hilukasz/2784422 to your computer and use it in GitHub Desktop.
function mySymbol(input){
var idoc = app.activeDocument;
if (input <= idoc.symbolItems.length-1) {
alert(idoc.symbolItems.length);
if (input) {
this.mySymbolIndex = input;
} else { this.mySymbolIndex = 0; }; //set up default symbol to first one if none is defined
this.width = function () {
var symbolWidth = Math.round(idoc.symbolItems[this.mySymbolIndex].width); //convert float to int
return symbolWidth;
}
this.height = function () {
var symbolHeight = Math.round(idoc.symbolItems[this.mySymbolIndex].height); //convert float to int
return symbolHeight;
}
}
else {
alert('There are only '+idoc.symbolItems.length+'symbols in your library, you selected '+input+'try a lower number');
this.height = 0;
this.width = 0;
}
}
var firstSymbol = new mySymbol(1);
firstSymbol.width();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment