Skip to main content
Inspiring
September 14, 2017
Question

[AS][CC2017] Relink file in smart object layer

  • September 14, 2017
  • 1 reply
  • 1772 views

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

This topic has been closed for replies.

1 reply

c.pfaffenbichler
Community Expert
Community Expert
September 18, 2017

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?

Davide_Barranca12040269
Legend
September 18, 2017

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

Davide Barranca - PS developer and authorwww.ps-scripting.com
tmmlsAuthor
Inspiring
September 20, 2017

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.