Python + Photoshop


#21

@Drew:
I just meant that unlike some apps Photoshop exposes many separate COM servers, for doing various things. Like having to do a new Dispatch for “ExportOptionsSaveForWeb” in the example I had. That’s all I meant. There’s still mainly one way to do a given thing, you just may need to create a new COM client object here and there.

@Dragonboy:
Did you give up because you’re still having problems? Did Kovac’s suggestions not help? Also, for COM reference, I’d suggest using the VBScript Reference instead of the one for Javascript.


#22

[QUOTE=Adam Pletcher;4782]
@Dragonboy:
Did you give up because you’re still having problems? Did Kovac’s suggestions not help?.[/QUOTE]

Yes… I tried to change the code like Kovac suggested, but I encountered the same error. So I went back to the approach by using “ScriptingLister”.
> Kovac Anyway thank you for your suggestion!

Also, for COM reference, I’d suggest using the VBScript Reference instead of the one for Javascript

I’ve never used VBScript via COM. I immediately try to use it. Thanks!


#23

Actually, I just meant that the VBScript reference matches what the COM functions are named, etc. I doubt the Javascript reference would be much help in finding the calls to make over COM.


#24

Really odd that it doesn’t work on your machine. I’ve copied and pasted it directly from here and it still worked as it should have on my machine using standard python 2.6.4 on IDLE with pywin32.

Best of luck using ScriptListener, I’ve never tried that one before.

Edit: Thanks for the heads up on that Adam, I’m new to this stuff so I probably would have beat my head on a few of the JS commands assuming they’d all work over COM.


#25

Oh…I misunderstood what you mean. Thank you for your explanation.
I understand what you mean. VBScript Reference is easier to find a match command for COM function than JavaScript Reference, isn’t it?

So I’ll try to adopt the Python(COM) approach by reference to 'ScriptingLister ’ and ‘VBScript Reference’.

Thank you!!


#26

Sorry to keep dropping the same questions over and over again. But it never huts to ask in case someone has a good idea.

Has anyone been able to do a similar win32com operation using 64bit version of Maya (2008 2009)

:smiley:


#27

Yep, we are doing that now. The latest version of win32com works on 64bit, but only with python 2.6 (i think)


#28

Dealing with this again at the moment, and found another good link for reference:

http://www.pcpix.com/Photoshop/ He’s talking about using the com bridge with C# but goes into how to translate some of the babble that you get out of the ScriptListener into something a little more useful.

useful toys like the list of translations: http://www.pcpix.com/Photoshop/enum.htm of the 4 letter abbreviations to the full Enum.


#29

tried that aswell, but never got wxpython and win32com to work together in maya :confused: was on a mission to make a 64bit build for python 2.5 but no luck…

I was working on a maya <> photoshop tool and I ended up using the python socket to talk to maya. But adam’s blog was a great help so thanks!


#30

So for 64bit Maya we have to use Maya 2010 :P… yet another reason to “upgrade” :smiley:


#31

[QUOTE=Erilaz;854]It does (After Effects has the same interface and scripting options as PS), but I can’t get the fundamental part working… ie. the client.Dispatch name!

EDIT: Turns out i’m an idiot… they’re right there in PythonWin tools… And no, AE doesn’t have one! I may have to set up an automation entry.[/QUOTE]

Hello , i’m searching to launch After effect with this method (or quicktime) do you have the link for what you call “PythonWin tools” , in python.org it’s just an IDE , i’m looking for the lists of string possible in
win32com.client.Dispatch(‘MyApplication.Application’). It seems to be impossible with after but it could be interesting to have a list of apps.

Anyway it works perfeclty in photoshop ! And it solved some rendering issues.
Thanks you for the blog Adam.

Edit : Of course , the point is to script actions in After , via python .
Whereas Launching after can be achieved with os.system(“start pathToAfter.exe”)


#32

[QUOTE=Aton.LERIN;20126]Hello , i’m searching to launch After effect with this method (or quicktime) do you have the link for what you call “PythonWin tools” , in python.org it’s just an IDE , i’m looking for the lists of string possible in
win32com.client.Dispatch(‘MyApplication.Application’). It seems to be impossible with after but it could be interesting to have a list of apps.

Anyway it works perfeclty in photoshop ! And it solved some rendering issues.
Thanks you for the blog Adam.

Edit : Of course , the point is to script actions in After , via python .
Whereas Launching after can be achieved with os.system(“start pathToAfter.exe”)[/QUOTE]

So has anyone been able to use win32com or comtypes to launch After Effects and use Python to script it.
I need to be able to replace path for footage file with data coming from shotgun and was hoping to keep with python to develop this tool.
Unfortunately, I can’t seem to fin the right progid to launch AE.

Any help would be much appreciated ! :smiley:

Victor


#33

Why do you need to launch it with COM? Just look up the install location in registry and fire it up using the executable path with subprocess.Popen()


#34

Hello Adam, thanks for your reply.
I wanted to use the COM interface, because I need to replace the path of the footage files used inside the aep file.
And I wanted to perform this operation, right at the launch of AE.
And since the data I’m using for replacement comes from shotgun, I wanted to do the whole thing in python.

Tell me if I’m not giving you enough informations.


#35

You can connect to the app using com once it’s finished starting up. You don’t need to actually launch the app over com, however.


#36

I tried as much as I could but I can’t seem to get it to work.
Whenever I try to do :

comtypes.client.CoGetObject('AfterEffects.Project.90')

or any try
I get nothing but an error.
I guess I might be missing something…
I read the docs about the displayName of the windows documentation but can’t seem to have found any indication.
Do you have any further leads ?

Thanks for your help :slight_smile:


#37

try no version, ‘AfterEffects.Project’ or ‘AfterEffects.Application’. also check your registry in HKEY_CLASSES_ROOT for AfterEffects* and see what is there to use


#38

Hi TheMaxx,

Thanks for your reply.
First I’d like to clarify some things :
-I’ve tried it so far with only After Effects CS5 (currently installing AE CS6 CC to check if I get any chance :slight_smile: )
-I’ve looked everywhere in my registry. I can’t seem to find any AfterEffects.Application entry in the HKEY_CLASSES_ROOT
-I only have :
or these entries :

I guess the AfterEffects.Project seems to be the progid I must use. However when i try to type in a python shell :

comtypes.client.CreateObject('AfterEffects.Project')

I only get this :

Traceback (most recent call last):
  File "<pyshell#36>", line 1, in <module>
    comtypes.client.CreateObject('AfterEffects.Project')
  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

Thanks for your help ! :slight_smile:


#39

I haven’t really heard about anyone using COM to script After Effects. I have to deal with AE a lot (as well as Shotgun) and generally I just use extendscript. What exactly are you trying to accomplish?


#40

try this:

comtypes.client.CreateObject('AfterEffects.Project.100')

or

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

or

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