Executing script externally causes weird Photoshop error

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

Nightshade

Executing script externally causes weird Photoshop error

Post by Nightshade »

What I'm trying to do:
Use Python from inside Autodesk Maya, in order to open up Photoshop, open up a workfile and run a script.

What works and what doesn't work:
My Python code works exactly as it should. Below here I import the subprocess module so that I can run the Popen command in order to get Windows to open up Photoshop.
The other arguments that are sent with this command is the script path, and the path to my workfile. These paths are stored in those three variables called "photoshop", "script" and "texture"

Code: Select allimport subprocess

photoshop = r"X:\Adobe\Adobe Photoshop CC (64 Bit)\Photoshop.exe"
script = r"X:\Lolpath\test.jsx"
texture = r"X:\Lolpath\test.psd"

subprocess.Popen((photoshop, script, texture))
For those not familiar with Python, the r in front of the strings tells Python that the we are dealing with "raw" strings, meaning that spaces and slashes are completely ignored and are not dealt with as secondary commands, arguments or as escape characters. Anyway, this isn't a Python forum so this part of the code is actually irrelevant - but I'm posting it to you just in case some of you familiar with Python wanna make sure that my syntax isn't invalid or something.

On to the problem.
When trying to execute my script externally, Photoshop gives me this weird shit:
Code: Select allError 8800: General Photoshop error occured. This functionality may not be available in this version of Photoshop.
With a reference to a piece of code that IS completely valid!!

I know with 100% certainty that the scripts I'm trying to run have no faults in them, because I can run them manually inside Photoshop. I started out by trying this javascript:
http://blog.xshock.de/content/resources ... rbelow.zip ... rbelow.zip

...but I considered that "hey, maybe something is off with it" so I did the very same test on a script that is NATIVE to Photoshop (i.e. it comes with the installation).
So I tried executing a NATIVE extendscript in the Photoshop\Presets\Scropts -folder, called "Fit Image.jsx":
Code: Select allIOError: General Photoshop error occured. This functionality may not be available in this version of Photoshop.

Has anyone seen anything like this before? I'm sure there must be other people here who like me, have tried executing a photoshop script externally.
Also, I would like to further point out that this isn't a Python issue. I first thought that maybe subprocess tried to execute the scripts before the workfile was open, so I tried running all of this again but with Photoshop AND the workfile open: same error messages
PhotoSpot_scripter

Executing script externally causes weird Photoshop error

Post by PhotoSpot_scripter »

yes, there are others who have done this. You are not alone.
http://adobescripting.com/MAIN_wp/case- ... snapshots/ ... snapshots/

I was using MEL not Python, but... same idea. What I found works better is to run a DROPLET that calls the JSX, rather then trying to source the JSX file itself. It takes a few steps to setup, but once you have the droplet, execution is very easy.

To create the droplet:
record your JSX file as action. (be sure to NOT have the ESTK open when you do this, or it will not record.)
Create a droplet from the action using: File > Automate > createDroplet

Then run a system execute of the droplet in your Maya Python script. (code below is on a PC and in MEL, but , I'm sure you can translate accordingly.

global proc runBuildFacePSD ( string $fileToDrop ) {
//Run Photoshop Droplet
string $dropletLoc = ("S:\\tools_pf\\photoshop\\FaceBuilder\\BuildFacePSDCS5.EXE");
$cmd = ($dropletLoc + " " + $fileToDrop) ;
system ($cmd) ; }

Yes, its a small pain, because every time you update the JSX file, you need to re-create the droplet. but I found this works great.

Feel free to find me at AdobeScripting if you have any more questions. I started scripting in Photoshop doing 3D work combining Adobe Automation with Maya/Max/Softimage automation for films and games... its a powerfull mix.
Goodluck!
Nightshade

Executing script externally causes weird Photoshop error

Post by Nightshade »

Fortunatly I know MEL and am quite good with it ^^
First time I hear of droplets - and I've used Photoshop for like a decade lol.
What versions of Photoshop support this, and is there any backwards compatibility issues that I should know about?

It all seems like a good idea but the longer my pipeline is the larger the risk that something screws up - especially when my future tool(s) will be used on many types of machines :/ So I'm a bit sceptical.

Btw I found out why I got those weird errors now. It's because of the order of the arguments in that Python code.
The argument order has to be: photoshop, texture and THEN the script. In retrospect this makes total sense considering the nature of the subprocess module. Each of the arguments will be executed individually, but only once a "green light" has been given. So the first argument is executed (opens Photoshop), and then subprocess gets a green light to execute the second argument (script) - but does this prematurely before everything has been started up by Photoshop. The result is that Photoshop has no way of dealing with those scripts, throwing a general error at the user. So yeah, subprocess does things prematurely it seems. Because when I put the arguments in the right order, the script was executed before the workfile was fully loaded, resulting in nothing. BUT, if I had Photoshop AND the workfile already open before running that Python code: then my javascript executed just fine!!

So I guess that the solution to this is to throw two separate subprocess calls: One for opening Photoshop and the workfile, another to execute the script.
Now the problem is that I have to make this connection a two-way street because Photoshop needs to tell Maya somehow that "the workfile has been open". Sigh...
PhotoSpot_scripter

Executing script externally causes weird Photoshop error

Post by PhotoSpot_scripter »

Glad you got it working.

If you Do decide to go with droplets, they have been around since WAY back. I know I started using them in CS1, and they might have been even before that. They are pretty robust. Basically if you're action runs in your version of PS, then the droplet will. Of course, nuances in ExtendScript change between versions, so I'd be more careful of that. Droplets are awesome, Google them up for more info. They are the the key to getting Photoshop Functionality as a system executable.

I'd suggest you create the droplet in the version of PS that your team is going to be using... but I've had droplets around that automate Photoshop functions that were created in CS1 or CS2 that are still getting used today in CC. (Scripts needed to get updated, but if you're just recording basic PS menu stuff,they are pretty reliable.)

WARNING:
ALWAYS keep your Action that created the droplet(and any associated JSX files) together with the droplet. If you lose the action, and need to update the droplet... its a huge pain in the @ss. There are Xtools out there that can help, but its so much easier if you just keep them together.
Nightshade

Executing script externally causes weird Photoshop error

Post by Nightshade »

Oh trust me: I'll definetly be taking a look at those droplets!
technologywell
Posts: 1
Joined: Tue Jul 06, 2021 2:03 pm

Re: Executing script externally causes weird Photoshop error

Post by technologywell »

Nightshade wrote: Wed Jan 15, 2014 9:15 pm What I'm trying to do:
Use Python from inside Autodesk Maya, in order to open up Photoshop, open up a workfile and run a script.

What works and what doesn't work:
My Python code works exactly as it should. Below here I import the subprocess module so that I can run the Popen command in order to get Windows to open up Photoshop.
The other arguments that are sent with this command is the script path, and the path to my workfile. These paths are stored in those three variables called "photoshop", "script" and "texture"

Code: Select allimport subprocess

photoshop = r"X:\Adobe\Adobe Photoshop CC (64 Bit)\Photoshop.exe"
script = r"X:\Lolpath\test.jsx"
texture = r"X:\Lolpath\test.psd"

subprocess.Popen((photoshop, script, texture))
For those not familiar with Python, the r in front of the strings tells Python that the we are dealing with "raw" strings, meaning that spaces and slashes are completely ignored and are not dealt with as secondary commands, arguments or as escape characters. Anyway, this isn't a Python forum so this part of the code is actually irrelevant - but I'm posting it to you just in case some of you familiar with Python wanna make sure that my syntax isn't invalid or something.

On to the problem.
When trying to execute my script externally, Photoshop gives me this weird shit:
Code: Select allError 8800: General Photoshop error occured. This functionality may not be available in this version of Photoshop.
With a reference to a piece of code that IS completely valid!! download gta 5 ios

I know with 100% certainty that the scripts I'm trying to run have no faults in them, because I can run them manually inside Photoshop. I started out by trying this javascript:
http://blog.xshock.de/content/resources ... rbelow.zip ... rbelow.zip

...but I considered that "hey, maybe something is off with it" so I did the very same test on a script that is NATIVE to Photoshop (i.e. it comes with the installation).
So I tried executing a NATIVE extendscript in the Photoshop\Presets\Scropts -folder, called "Fit Image.jsx":
Code: Select allIOError: General Photoshop error occured. This functionality may not be available in this version of Photoshop.

Has anyone seen anything like this before? I'm sure there must be other people here who like me, have tried executing a photoshop script externally.
Also, I would like to further point out that this isn't a Python issue. I first thought that maybe subprocess tried to execute the scripts before the workfile was open, so I tried running all of this again but with Photoshop AND the workfile open: same error messages
facing same error. Did you find the solution?
EthanWinters
Posts: 1
Joined: Mon Sep 13, 2021 3:50 am

Re: Executing script externally causes weird Photoshop error

Post by EthanWinters »

Hey Sir, if you having such error as you mentioned the code
Code: Select allimport subprocess

photoshop = r"X:\Adobe\Adobe Photoshop CC (64 Bit)\Photoshop.exe"
script = r"X:\Lolpath\test.jsx"
texture = r"X:\Lolpath\test.psd"

Well, you better close your internet connection and restart your system. Also, I suggest you should update the Photoshop as well. Kinemaster Diamond
arnold
Posts: 1
Joined: Sat Dec 04, 2021 9:01 am

Re: Executing script externally causes weird Photoshop error

Post by arnold »

Have you ascertained that all the Scripts are installed and that they work on CS2? whatsapp mod
im2033thomas
Posts: 1
Joined: Sat Jan 22, 2022 10:44 am

Re: Executing script externally causes weird Photoshop error

Post by im2033thomas »

Rather than digging through every setting and testing every tool, you can just restore Photoshop to its default state. To do so, open Photoshop and press Alt+Control+Shift on a Windows PC or Option+Command+Shift on a Mac. When you're asked if you want to “Delete the Adobe Photoshop Settings File,” click “Yes.” That's all done, Thank You..