Automating Photoshop with a DotNet Class Library and COM interop

35 votes
Author: 
LoneRobot

Automating Photoshop with a DotNet Class Library and COM interop

 

Recently, there was a thread on CGTalk
about whether it was possible to save out multiple render passes into a
layered photoshop file from 3dsMax itself. This question had been
sitting in the back of my mind ever since and I decided to look into
whether it was possible. My first thought was that there was an
external image library out there that could do the job. However,
finding a good solution meant I didn’t want to have to purchase
software for something that was purely research. I already own a great
library - AIL, which is based on the freeimage library. Alas, while
this can open Photoshop documents, it can not create, structure and
save them. However, after a bit of research on the Adobe site, I found
that it is indeed possible to do all these things using DotNet.

With Photoshop, Adobe has included an object library assembly.
This is a clever assembly that allows you to write custom scripts and
automate the Photoshop UI. “Hang on Shirley”, I hear you cry, “We don’t
need that - I own a Mac and we’ve got actions for that, I can do
everything I need from there! It’s fun, too”.

Well, yes and no. This programmed method still could be the ‘droids you are looking for’.

Actions mean that you obviously
need to have it recorded at some point, and be able to trigger the
start of the action from within the photoshop application. However,
when using maps in 3dsMax there are many occasions when you need to
perform a tweak here and there to a map, and the workflow is broken as
you have to open it in another program and perform the tasks.

Some other benefits (from the Adobe scripting guide) are -

  • You can add conditional logic, so that the
    script automatically makes “decisions” based on the currentsituation.
    For example, you could write a script that decides which color border
    to add depending onthe size of the selected area in an image: “If the
    selected area is smaller than 2 x 4 inches, add a greenborder;
    otherwise add a red border.”
  • A single script can perform actions that
    involve multiple applications. For example, depending on thescripting
    language you are using, you could target both Photoshop CS3 and another
    Adobe CreativeSuite 3 Application, such as Illustrator® CS3, in the
    same script.
  • You can open, save, and rename files using scripts.
  • You can copy scripts from one computer to
    another. If you were using an Action and then switchedcomputers, you’d
    have to recreate the Action.
  • Scripts provide more versatility for
    automatically opening files. When opening a file in an action, youmust
    hard code the file location. In a script, you can use variables for
    file paths.

With this in mind, you are presented with the
opportunity that you can automate Photoshop from within the 3dsMax
interface. For example, you could have a maxfile that renders multiple
passes and calls a post-render script when it finishes, triggering the
creation of a psd composite of all the images. You could use it to call
a function to overlay an Ambient Occlusion pass on notification of a
completed render. You could select an object in the 3dsMax viewport and
have Photoshop apply a Gaussian Blur or an artistic effect to the
Diffusemap without leaving the 3dsMax Interface. The applications can
be as specialised as you want but completely customisable in the same
breath.

To read the rest of this article, click the link on to find information on how to create a Photoshop control assembly for 3dsMax

Video URL: 

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Hani Tiby's picture

Excellent work : ) So what

Excellent work : )
So what about Adobe after effects ?? lol

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.