Here is where I’m at:
// Check if any document is open
if (app.documents.length > 0) {
var doc = app.activeDocument;
// Check if any frame is selected
if (doc.selection.length > 0 && doc.selection[0].constructor.name == "Rectangle") {
var selectedFrame = doc.selection[0];
// Check if the selected frame contains any graphics
if (selectedFrame.allGraphics.length > 0) {
// Select the first graphic inside the frame (assuming it's an image)
var graphic = selectedFrame.allGraphics[0];
graphic.select();
} else {
alert("The selected frame does not contain any graphics.");
}
} else {
alert("Please select a frame to proceed.");
}
} else {
alert("No document is open.");
}
when I have the frame selected and run the script, nothing happens. I do get an alert if I don’t select a frame. I have tried many variations of this but get nowhere. I AM VERY NEW TO CODING but learning a lot on here. thank you
2
Answers
Try changing
graphic.select()
toapp.select(graphic);
Here’s a more flexible approach that simply checks to see if your selection has a graphics property. If so, it selects the first graphic associated with it.
I’m used to get a selected graphic this way: