Copy link to clipboard
Copied
Hi,
I need to relink an external file, located inside a smart object layer using AppleScript.
Does anyone know if this can be done ? Currently I have ...
tell application "Adobe Photoshop CC 2017"
tell current document
set myLayer to my getLayerByName("Example")
-- Relink external file located inside smart object layer
end tell
end tell
on getLayerByName(myLayerName)
tell application "Adobe Photoshop CC 2017"
tell current document
repeat with i from 1 to count layers
set currentLayerName to (name of layer i) as string
if currentLayerName is equal to myLayerName then
return layer i
end if
end repeat
end tell
end tell
end getLayerByName
Thanks
Copy link to clipboard
Copied
I suppose that by now you have concluded yourself that AppleScript is not popular for Photoshop Scripting among the regulars on this Forum.
Could you do it in JavaScript instead?
Copy link to clipboard
Copied
tmmls, some parts of the PS commands are not directly exposed to the Scripting API via the Document Object Model – we have to resort to ActionManager (AM: a powerful yet unfriendly set of the ExtendScript language).
As far as I know, AppleScript can't deal with AM, so your best option is to look for a JS solution, save it as a snippet in a .jsx file and then "do javascript" passing the file reference – I'm not expert in AppleScript so please check its documentation for the details.
Hope this helps,
Davide
Copy link to clipboard
Copied
Hi Davide,
Thank your for the usefull information. I did some small tests in Javascript and replaying recorded javascript code using the scriptListener doesn't always work.
Copy link to clipboard
Copied
replaying recorded javascript code using the scriptListener doesn't always work
Do you mean when played from AS or on its own?
Copy link to clipboard
Copied
Playing from the ExtendScript Toolkit targeting Adobe Photoshop
Copy link to clipboard
Copied
Are you sure you copied the complete pertinent code and that the File can support the task?
What is the error message?
Please post screenshots.