Archive for January, 2011

Formatting Text Ranges in Photoshop

In response to an earlier post, “Entering and Formatting Text” (here) a couple of folks asked if there was a way to apply formatting to ranges of text in a Photoshop text layer. It’s certainly not obvious from the Photoshop scripting object model how one would go about doing this—in fact, I don’t think it’s possible, and said so in my response to the comments.

This exchange got me thinking. So it’s impossible—how do you do it? I knew that Photoshop has another way of scripting (in addition to the object model), the Action Manager. I made a mental note to pursue this course, and promptly got distracted by other work.

In the comments section of the earlier post, Jeremy Knudsen kindly posted a pointer to an exchange from the (excellent) PS-Scripts forum, in which (excellent) Photoshop scripter xbytor described a way to work with text ranges in Photoshop. xbytor’s (excellent) xtools Photoshop scripting package for ExtendScript looked like it might solve the problem. I considered asking xbytor for permission to port the package to ActionScript, but decided to try solving the problem myself. There’s a lot of code in the xTools package, and I was looking for a lighter-weight solution.

This led me back to Photoshop, the Action Manager, and the Script Listener plug-in.

You can find the example project here.

Continue reading…

Putting It All Together: Path Effects

In these blog posts, I’m trying to create a series of “building blocks” that CS SDK users can put together to make CS Extensions. Need to draw things with your CS Extension? You can pull drawing routines from the “Drawing Paths: The Basics” post. Want to have your CS Extension respond to document open/close events? Grab the DocumentWatcher class from the “Watching the Detections” post.

At the same time, I’m thinking that some CS SDK users are coming to the Creative Suite without deep knowledge of at least some of the applications. A developer who has spent years working with Flash might not know (or want to know) the finer details of drawing paths in Illustrator, or setting type in InDesign.

My goal is to make it possible for these developers to get things done in Illustrator, InDesign, and Photoshop relatively quickly, without having to learn the document object model of each application (each one different). To that end, I’ve provided functions that encapsulate some of the complexity inside applications-specific functions.

Sadly, for this post, we’ll have to leave Photoshop behind, as that application doesn’t really provide a way to tell if a path is selected. (Or, I should say, it doesn’t provide an obvious way—I’m still looking.)

To see how this might work for you, let’s put together a new CS Extension using parts and pieces from my earlier blog posts. We’ll create an extension that applies various effects to the paths of page items selected in the host application, and we’ll get most of the code from the Drawing and DocumentWatcher projects.

This project also gives me a chance to make a point about Creative Suite Extensions in general: I think that we developers often think only in terms of productivity tools—writing XMP metadata or setting up defaults for a workgroup, that sort of thing. We tend to forget that automation can be used to add creative tools and new artistic effects.

The project for this example is here:

PathEffects
Continue reading…