• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

How can I convert a layer to Smart Layer in Photoshop using AppleScript?

New Here ,
Jul 21, 2020 Jul 21, 2020

Copy link to clipboard

Copied

I've searched the documentation, AppleScript dictionary as well as the Adobe forums here and can't find a way to convert a layer to a Smart Object. Is it possible?

Views

198

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 17, 2024 Apr 17, 2024

I haven't checked the AS scripting reference, however, both AS and JS DOM coding is limited. What the DOM doesn't cover, one can usually achieve using AM code (Action Manager).  The most accessible form of this is recorded by the ScriptingListener plug-in.

AppleScript can call "inline" code or reference an external script file to perform tasks not directly covered in the AS DOM.

 

The AM code to convert the active layer to an Embedded Smart Object:

 

executeAction(stringIDToTypeID("newPlacedLaye
...

Votes

Translate

Translate
Adobe
Community Expert ,
Jul 21, 2020 Jul 21, 2020

Copy link to clipboard

Copied

Are you trying to Automate this fucntion? If so ehy not use Actions?

 

WM

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 22, 2020 Jul 22, 2020

Copy link to clipboard

Copied

Yes actually I'm trying to automate a series of steps like resizing and saving where creating a smart object is part of it but without using actions 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 17, 2024 Apr 17, 2024

Copy link to clipboard

Copied

Did you find a solution, I searched a lot and I can't find it either... 😉

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 17, 2024 Apr 17, 2024

Copy link to clipboard

Copied

I haven't checked the AS scripting reference, however, both AS and JS DOM coding is limited. What the DOM doesn't cover, one can usually achieve using AM code (Action Manager).  The most accessible form of this is recorded by the ScriptingListener plug-in.

AppleScript can call "inline" code or reference an external script file to perform tasks not directly covered in the AS DOM.

 

The AM code to convert the active layer to an Embedded Smart Object:

 

executeAction(stringIDToTypeID("newPlacedLayer"), undefined, DialogModes.NO);

 

The AppleScript code:

 

tell application "Adobe Photoshop 2024"
	
	set js to "executeAction(stringIDToTypeID(\"newPlacedLayer\"), undefined, DialogModes.NO);"
	
	do javascript js
	
end tell

 

Notice how the " double-quotes in the original code have been escaped \" with a backslash as the JS code is contained within open/close double-quotes in the AS code.

 

Another option rather than escaping the double-quotes, is to use single-quotes:

 

tell application "Adobe Photoshop 2024"
	
	set js to "executeAction(stringIDToTypeID('newPlacedLayer'), undefined, DialogModes.NO);"
	
	do javascript js
	
end tell

 

If you wanted to reference an external JSX file:

 

tell application "Adobe Photoshop 2024"
	activate
	do javascript of file "~/Desktop/createSO.jsx"
end tell

 

or

 

tell application "Adobe Photoshop 2024"
	activate
	do javascript (file "Users:username:Desktop:createSO.jsx")
end tell

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 17, 2024 Apr 17, 2024

Copy link to clipboard

Copied

Wooow you're a boss! 

I've been trying to do this with Applescript for months and I can't find a solution. Even ChatGpt can't do it 😉 Congratulations on your code

It works perfectly.

It was the only thing I didn't know how to do with Applescript on Photoshop. I don't know about Script Listener but I'll look more carefully.
Thank you very much Stephen!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 17, 2024 Apr 17, 2024

Copy link to clipboard

Copied

Hi Stephen

I can't install Scripting Listener on my iMac Pro.
A priori, according to the forum, few people manage to do it.
Have you installed it on a recent mac?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 17, 2024 Apr 17, 2024

Copy link to clipboard

Copied

I still use an Intel Mac.

 

I doubt that Adobe will update the plug-in to work with Apple Silicon as Adobe are transitioning scripting from ExtendScript and Action Manager to UXP JS and batchPlay... Later versions of Photoshop allow conversion directly to batchPlay JS without needing a plugin.

 

I haven't done much work with UXP, so I'll need to test if AS can use such code.

 

As UXP JS is cross-platform, one may have to do without using AppleScript if it can't run UXP JS.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 17, 2024 Apr 17, 2024

Copy link to clipboard

Copied

LATEST

An iMac Pro is Intel, so it should work. I have used it with my 2019 MacBook Pro/Sonoma so yes it does work.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines