I can't figure out how to use this Guide property in CS5.
I'm trying stuff like this,
alert(app.activeDocument.direction);
alert(app.activeDocument.guides.direction);
And am not getting any relevant info. I have two guides placed and can't get the info I want from them.
Also, if I had like 5 guides, how would I find their coordinates?
Here's the relevant info from the Scripting Guide (JSX);
Using Guides commands in CS5 to find Guide Coordinates?
Using Guides commands in CS5 to find Guide Coordinates?
Code: Select allvar guides = app.activeDocument.guides;// get the current doc's guides
var guideArray = [];
for( var g = 0; g < guides.length; g++ ){
guideArray.push( [guides[g].direction, guides[g].coordinate ]);// store the guide properties for later
}
alert(guideArray);
Found this VERY helpful code in another thread from Mike Hale. I added the alert part.
Quick question,
var guideArray = [];
Is that a JS shortcut for creating a new array? I thought the command was
var guideArray = new Array();
var guideArray = [];
for( var g = 0; g < guides.length; g++ ){
guideArray.push( [guides[g].direction, guides[g].coordinate ]);// store the guide properties for later
}
alert(guideArray);
Found this VERY helpful code in another thread from Mike Hale. I added the alert part.
Quick question,
var guideArray = [];
Is that a JS shortcut for creating a new array? I thought the command was
var guideArray = new Array();
Using Guides commands in CS5 to find Guide Coordinates?
Thanks! I appreciate the reply. Really noob question. Not that confident at googling answers right now, having a tough time chewing through some of the terminology on some sites.
Using Guides commands in CS5 to find Guide Coordinates?
var guideArray = []; is an implicit way to create an array.
var guideArray = new Array(); is the explicit way.
For the most part they do the same thing, but for some reason the explicit method is more often used with arrays. For numbers, implicit is more common. You don't often see var a = new Number(5); but it does about the same as var a = 5;
var guideArray = new Array(); is the explicit way.
For the most part they do the same thing, but for some reason the explicit method is more often used with arrays. For numbers, implicit is more common. You don't often see var a = new Number(5); but it does about the same as var a = 5;
Using Guides commands in CS5 to find Guide Coordinates?
The 'new' is also optional so in many cases you will also see…
Code: Select allvar guideArray = Array();
Code: Select allvar guideArray = Array();