Copy link to clipboard
Copied
Sometimes, it is necessary to switch to the direct selection tool (white arrow) in order to recognize it.
Sometimes, it is again necessary to use the selection tool (black arrow) to recognize it.
For example:
// open the paths in photoshop
openPathsInPhotoshop(paths);
This requires the selection tool.
If it is a direct selection tool, it will report an error.
Is it possible to pass through?
Because sometimes we don't need to distinguish between them.
Thank you very much.
I think you need a function to check your selection for an image, something like this:
main()
function main(){
//if checkSelection() returns no image send alert and stop the script
if (checkSelection() == undefined) {
alert("No Image Selected")
return
}
//get the file path
var fp = checkSelection()
alert("This selection’s file path: " + fp)
}
/**
* Checks if a selection is an image or contains an image
* @ return the image file path
*/
function c
Try this for your main function:
(function () {
if (0 === app.documents.length)
return alert('Please open a document and try again');
var doc = app.activeDocument,
items = doc.selection;
if (0 === items.length)
return alert('Please select a picture frame');
// collect paths for each selected item
var paths = [],
links = [];
for (var i = 0; i < items.length; i++) {
var item = items[i];
// maybe user selected the image,
...
Copy link to clipboard
Copied
Sometimes it is necessary to distinguish between them.
Sometimes it is not necessary to distinguish them.
That's the point of having two tools.
Copy link to clipboard
Copied
I think you need a function to check your selection for an image, something like this:
main()
function main(){
//if checkSelection() returns no image send alert and stop the script
if (checkSelection() == undefined) {
alert("No Image Selected")
return
}
//get the file path
var fp = checkSelection()
alert("This selection’s file path: " + fp)
}
/**
* Checks if a selection is an image or contains an image
* @ return the image file path
*/
function checkSelection(){
var sel, p
//check for a selection
if (app.activeDocument.selection.length > 0) {
//check the selection for an image
sel = app.activeDocument.selection[0];
if (sel.constructor.name === "Image") {
p = sel.itemLink.filePath
} else {
try {
p = sel.images[0].itemLink.filePath
}catch(e){}
}
}
//retuns a file path or undefined
return p
}
Copy link to clipboard
Copied
Hi rob day.
Thank you very much.
Yes, need to be judging the different states of choice.
This is worth learning from me.
Now it's time to go with the m1b option for now, time is running out.
Copy link to clipboard
Copied
To get the image path without switching tools: Layers Panel: Open the Layers panel and hover over the image to see its details. Info Panel: Open the Info panel (Window > Info) for position and path details. Right-click: Right-click the image and select "Properties" or "Reveal in Finder/Explorer". These methods allow you to access the path easily!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now