Copy link to clipboard
Copied
With following script I can create some horizontal guide lines with specific horizontal coordinates:
var guideCoordinates = [
201,
116,
373,
288,
536,
454,
693,
615,
843,
763,
986,
907,
1124,
1046,
1256,
1178,
1394,
1309,
1503,
1428,
1631,
1545,
1741,
1657,
1837,
1765,
1939,
1867,
2047,
1966
];
var doc = app.activeDocument;
// Loop through the horizontal guide coordinates and create guides
for (var i = 0; i < guideCoordinates.length; i++) {
var y = guideCoordinates[i];
// Create horizontal guide
var horizontalGuide = doc.guides.add(Direction.HORIZONTAL, UnitValue(y, "px"));
}
Now I want to select between every two horizontal guide lines by script automatically.
for example:
Select between 201 and 116 horizontal coordinates
add selection of 373 and 288 horizontal coordinates to previous selection
add selection of 536 and 454 horizontal coordinates to previous selection
add selection of 693 and 615 horizontal coordinates to previous selection
...
...
...
please help me to complete this script.
No need answer.
I fixed problem by following script:
var doc = app.activeDocument;
var guides = doc.guides;
// Initialize the selection with the first guide line
var firstGuide = guides[0];
var startY = firstGuide.coordinate.as("px") - 1;
var endY = guides[1].coordinate.as("px") + 1;
var initialSelection = Array(
[0, startY],
[doc.width, startY],
[doc.width, endY],
[0, endY]
);
doc.selection.select(initialSelection);
// Loop through all other guide lines to accumulate selecti
...
Copy link to clipboard
Copied
No need answer.
I fixed problem by following script:
var doc = app.activeDocument;
var guides = doc.guides;
// Initialize the selection with the first guide line
var firstGuide = guides[0];
var startY = firstGuide.coordinate.as("px") - 1;
var endY = guides[1].coordinate.as("px") + 1;
var initialSelection = Array(
[0, startY],
[doc.width, startY],
[doc.width, endY],
[0, endY]
);
doc.selection.select(initialSelection);
// Loop through all other guide lines to accumulate selections
for (var i = 2; i < guides.length; i += 2) {
startY = guides[i].coordinate.as("px") - 1;
endY = guides[i + 1].coordinate.as("px") + 1;
var selectionToAdd = Array(
[0, startY],
[doc.width, startY],
[doc.width, endY],
[0, endY]
);
// Add the new selection to the existing selection with Shift key
doc.selection.select(selectionToAdd, SelectionType.EXTEND);
}