Another approach would be to turn off the style, get the bounds of the layer, then do an Undo to turn the styles visibilities back to the correct state. Sure quicker than dupe-ing the layer.
-X
Get the VALUE of AnchorPosition.BOTTOMLEFT??
Get the VALUE of AnchorPosition.BOTTOMLEFT??
Thanks for the feedback, guys. I like the undo idea as well...
Id have to look that one up...Im guessing someling like history -1 or the actual undo commad is how you do that?
I actually end up making a new document to copy merged/paste into later on in the script in order to save out the current layer as a file, so I can really probably get the "final bounds" from that...however, does paste() paste the data in the buffer in the same place as it was copied from (x,y)or does it simply paste it in the center of the doc?
Thanks again, guys!
-Brian-
Id have to look that one up...Im guessing someling like history -1 or the actual undo commad is how you do that?
I actually end up making a new document to copy merged/paste into later on in the script in order to save out the current layer as a file, so I can really probably get the "final bounds" from that...however, does paste() paste the data in the buffer in the same place as it was copied from (x,y)or does it simply paste it in the center of the doc?
Thanks again, guys!
-Brian-
Get the VALUE of AnchorPosition.BOTTOMLEFT??
Here's how I undo and redo...
Code: Select allcTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
Stdlib = function() {}
Stdlib.hist = function(dir) {
function _ftn() {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated(cTID("HstS"), cTID("Ordn"), cTID(dir));
desc.putReference(cTID("null"), ref);
executeAction(cTID("slct"), desc, DialogModes.NO);
}
_ftn();
};
Stdlib.undo = function () {
Stdlib.hist("Prvs");
};
Stdlib.redo = function () {
Stdlib.hist("Nxt ");
};
-X
Code: Select allcTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
Stdlib = function() {}
Stdlib.hist = function(dir) {
function _ftn() {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated(cTID("HstS"), cTID("Ordn"), cTID(dir));
desc.putReference(cTID("null"), ref);
executeAction(cTID("slct"), desc, DialogModes.NO);
}
_ftn();
};
Stdlib.undo = function () {
Stdlib.hist("Prvs");
};
Stdlib.redo = function () {
Stdlib.hist("Nxt ");
};
-X
Get the VALUE of AnchorPosition.BOTTOMLEFT??
Thanks X!
By the way guys, I don't know how much you've done with bounds tracking/manipulating, but it seems that outer glows, inner shadows, and inner glows all create rather odd and erroneous bounds data/cooridnates that do not actually exist within the layer if you take that same pixel data (copy merged, paste to new, bring that layer back in to original doc) from a fresh psd file. All other layer effects seem to keep/output accurate bounds differences as oopsed to the same object without layer effects added to the bounds...weird, huh?
-Brian-
By the way guys, I don't know how much you've done with bounds tracking/manipulating, but it seems that outer glows, inner shadows, and inner glows all create rather odd and erroneous bounds data/cooridnates that do not actually exist within the layer if you take that same pixel data (copy merged, paste to new, bring that layer back in to original doc) from a fresh psd file. All other layer effects seem to keep/output accurate bounds differences as oopsed to the same object without layer effects added to the bounds...weird, huh?
-Brian-
Get the VALUE of AnchorPosition.BOTTOMLEFT??
Here is yet another way to get the bounds
Code: Select allfunction ftn1(layerRef) {
function cTID(s) { return app.charIDToTypeID(s); };
var desc47 = new ActionDescriptor();
var ref22 = new ActionReference();
ref22.putProperty( cTID('Chnl'), cTID('fsel') );
desc47.putReference( cTID('null'), ref22 );
var ref23 = new ActionReference();
ref23.putEnumerated( cTID('Chnl'), cTID('Chnl'), cTID('Trsp') );
ref23.putName( cTID('Lyr '), layerRef.name );
desc47.putReference( cTID('T '), ref23 );
executeAction( cTID('setd'), desc47, DialogModes.NO );
var bounds = new Array();
//from Larry Ligon
var docRef = activeDocument;
var currentRuler = preferences.rulerUnits;
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();
preferences.rulerUnits = currentRuler;
return bounds;
};
var layerRef = activeDocument.activeLayer;
var layerBounds = ftn1(layerRef);
alert(layerBounds);
Code: Select allfunction ftn1(layerRef) {
function cTID(s) { return app.charIDToTypeID(s); };
var desc47 = new ActionDescriptor();
var ref22 = new ActionReference();
ref22.putProperty( cTID('Chnl'), cTID('fsel') );
desc47.putReference( cTID('null'), ref22 );
var ref23 = new ActionReference();
ref23.putEnumerated( cTID('Chnl'), cTID('Chnl'), cTID('Trsp') );
ref23.putName( cTID('Lyr '), layerRef.name );
desc47.putReference( cTID('T '), ref23 );
executeAction( cTID('setd'), desc47, DialogModes.NO );
var bounds = new Array();
//from Larry Ligon
var docRef = activeDocument;
var currentRuler = preferences.rulerUnits;
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();
preferences.rulerUnits = currentRuler;
return bounds;
};
var layerRef = activeDocument.activeLayer;
var layerBounds = ftn1(layerRef);
alert(layerBounds);