How do I convert the selection into a final array object?
Hi everyone.
My function only accepts “objects.” So I first need to convert the selection state into “objects,” ideally in array form.
My model is structured as follows:
Some parts are incorrect; please point them out.
Regardless of the cursor's state, the final `sel` should be an array object with a "length" property.
Thank you.
Currently, I cannot determine the three states of the cursor when it selects an image (including white arrow, black arrow, and pasted inside).
Additionally, the cursor's position within and outside the table must be considered.
var doc = app.activeDocument;
// item represents the specific state of the cursor
var item = doc.selection[0];
// items holds multiple selected objects, e.g., multiple images or text boxes selected simultaneously.
var items;
// sel is my target for operations and must be an array object (containing text boxes, images, geometric shapes)
var sel;
// Example: When cursor is in a text frame (not within a table)
var textFrames = [];
var item = doc.selection[0];
if (item && item.hasOwnProperty(‘parentTextFrames’) && “Table” != item.parent.parent.constructor.name) {
sel = item.parentTextFrames;
for (var j = 0; j < sel.length; j++) {
movePBSel(sel[j], doc)
imageFitToColumn(sel[j]);
};
exit();
}
// When an image is selected
var gra = (item.hasOwnProperty(‘graphics’) && 1 === item.graphics.length);
if (
(gra && item.parent.parent.constructor.name != “Story”))
{
items = doc.selection;
if (“Image” == item.parent.constructor.name) {
Items = item.parent;
}
sel = items;
for (var j = 0; j < sel.length; j++) {
imgFit(sel[j])
};
exit();
}
