Copy link to clipboard
Copied
Perhaps something like this?
/*
Move Selection Top to Horizontal Guide Coordinate.jsx
v1.0 - 20th April 2023, Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-discussions/move-the-selection-below-the-guide-line/td-p/13738648
*/
#target photoshop
var savedRuler = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
if (activeDocument.guides.length === 1 && activeDocument.guides[0].direction == Direction.HORIZONTAL) {
var hGuidePos = activeDocument.guides[
...
Copy link to clipboard
Copied
Just to be clear on terminology, by reference line, do you mean guide? As in View menu > New Guide?
If so, will there only be one guide – or at least only one horizontal guide?
Copy link to clipboard
Copied
Perhaps something like this?
/*
Move Selection Top to Horizontal Guide Coordinate.jsx
v1.0 - 20th April 2023, Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-discussions/move-the-selection-below-the-guide-line/td-p/13738648
*/
#target photoshop
var savedRuler = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
if (activeDocument.guides.length === 1 && activeDocument.guides[0].direction == Direction.HORIZONTAL) {
var hGuidePos = activeDocument.guides[0].coordinate.value;
try {
activeDocument.selection.bounds;
var selTop = activeDocument.selection.bounds[1].value;
var vMove = selTop - hGuidePos;
moveSel(0, -vMove);
} catch (e) {
alert("There is no active selection!");
}
} else {
alert("There are multiple guides and or the guide is vertical!");
}
app.preferences.rulerUnits = savedRuler;
function moveSel(horizontal, vertical) {
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var reference = new ActionReference();
reference.putProperty(s2t("channel"), s2t("selection"));
descriptor.putReference(s2t("null"), reference);
descriptor2.putUnitDouble(s2t("horizontal"), s2t("pixelsUnit"), horizontal);
descriptor2.putUnitDouble(s2t("vertical"), s2t("pixelsUnit"), vertical);
descriptor.putObject(s2t("to"), s2t("offset"), descriptor2);
executeAction(s2t("move"), descriptor, DialogModes.NO);
}
Copy link to clipboard
Copied
Thank you for your help. Thank you