Is there a way to read the location of guides in JavaScript (on CS)? I'd like to write a script that will take a set of four guides and crop to them.
The process I'm envisioning is that a user would create a bounding box around part of an image by dragging out guides and would then invoke a script that would create a selection from the guides, crop to the selection and then be on its merry way.
Thanks, Doug
Reading the location of guides in JavaScript
-
Andrew
Reading the location of guides in JavaScript
Guides are not something I use but there was a long thread on using them at the Adobe forum, search for:
Create Guides via script ?
Andrew
Create Guides via script ?
Andrew
-
Larry Ligon
Reading the location of guides in JavaScript
You can have the user make a selection and then you can get the bounds of the selection in CS. Try this:
Code: Select allvar bounds = new Array();
var docRef = activeDocument;
preferences.rulerUnits = Units.PIXELS;
var layerSetRef = docRef.layerSets.add();
var layerRef = layerSetRef.artLayers.add();
docRef.activeLayer = layerRef;
docRef.selection.fill( app.foregroundColor);
bounds = layerSetRef.bounds;
layerSetRef.remove();
alert("bounds = " + bounds );
You can then crop to the bounds.
Larry
Code: Select allvar bounds = new Array();
var docRef = activeDocument;
preferences.rulerUnits = Units.PIXELS;
var layerSetRef = docRef.layerSets.add();
var layerRef = layerSetRef.artLayers.add();
docRef.activeLayer = layerRef;
docRef.selection.fill( app.foregroundColor);
bounds = layerSetRef.bounds;
layerSetRef.remove();
alert("bounds = " + bounds );
You can then crop to the bounds.
Larry
-
mlk
Reading the location of guides in JavaScript
Have you looked at what the script listener recorded ? I was able to create guides, change their color, removing them (though not one by one) through scripting, but I don't recall being able to individually edit their properties.