Python + Photoshop

Hi eharper and rgkovach123

Finally I gave up trying to use COM to script AE. I went with JSX (and it’s quite a lame scripting language imo…)
I was triying to achieve the following scenario :
[ol]
[li]Our compers need to get the AEP files of a shot to work locally on their machines
[/li][li]A python script allows them to choose a shot.
[/li][li]This script check with shotgun if the shot hasn’t been already assigned and a valid precomp (that is coming from another studio) version exists
[/li][li]If everything meets the expectation, then the AEP file is copied in an arborescence similar to the one on the server
[/li][li]The sources are staying on the server though, because we don’t want to slow everyone down by copying a few gigs.
[/li][li]Then I open After from Python using [/li]```
subprocess.Popen


[li]I must patch the sources to be remapped to the network ones (Using JSX script). Which brings me to a subquestion that you might shine a light on. I have a PSD file imported as comp in my source Aep file, is there an easy way to replace it ? Right now I am reimporting the PSD file and doing a [/li]```
replaceSource()

but I wonder if there’s a better solution.
[/ol]

Finally, after the comper has done his/her work, they have to publish it. Which means I have to do the reverse process, plus copy some files in the server arborescence and update shotgun.
There I’m quite done here.
I tried your commands and here’s the output

comtypes.client.CreateObject('AfterEffects.Application.130')

Traceback (most recent call last):
  File "<pyshell#25>", line 1, in <module>
    comtypes.client.CreateObject('AfterEffects.Application.130')
  File "C:\Python27\lib\comtypes\client\__init__.py", line 224, in CreateObject
    clsid = comtypes.GUID.from_progid(progid)
  File "C:\Python27\lib\comtypes\GUID.py", line 78, in from_progid
    _CLSIDFromProgID(unicode(progid), byref(inst))
  File "_ctypes/callproc.c", line 945, in GetResult
WindowsError: [Error -2147221005] Chaîne de classe incorrecte
>>> comtypes.client.CreateObject('AfterEffects.Project.100')
<POINTER(IUnknown) ptr=0x3dd140 at 293f0c8>
>>> comtypes.client.CreateObject('AfterEffects.Project.130')
<POINTER(IUnknown) ptr=0x3dd170 at 32f0ac8>

I can’t figure how to use this pointer.

Thanks a bunch guys

The idea here is that you need to reference your open Object to a variable e.g.:

from comtypes import client as ct

myApp = ct.CreateObject('AfterEffects.Application.130')

myApp.aNyMeThOdHeRe(xxxx)

Hope that helps and you solved your issue anyhow :wink:

There is also a class on Photoshop scripting and pipeline from Rigging Dojo https://ondemand.riggingdojo.com/Photoshop%20scripting

Hi All,
I want to share my open-source photoshop-python-api hope you will like it.

The examples were created with Photoshop Python API. Check it out at photoshop-python-api.readthedocs.io/examples.

1 Like