On Mar 23, 2011, at 2:29 PM, Fleisher, Ken wrote:
Thanks for all the replies. I guess I was on the right track originally, but got the syntax a little bit wrong. Your suggestions helped get me there. Additionally, there are two hang ups that I can’t seem to get around. I cannot set properties of the text object at the same time as creating the layer because it seems there is no text object yet to assign properties to. Also, I cannot set the contents of contents of the text layer in the same properties assignment because (well, I don’t know why, but the text doesn’t come out right).
I have come up with this so far which already has dramatically increased the speed. Many thanks to all for the suggestions.
Ken
tell application "Adobe Photoshop CS5"
set ruler units of settings to pixel units
tell current document
set h to height
set textlayer to make new art layer with properties {kind:text layer, name:"Text Layer"}
set textobj to text object of textlayer
set properties of textobj to {position:{10, h - 10}, justification:left, size:24, ¬
stroke color:{class:Lab color, value_L:55, value_a:20, value_b:0}, font:"Helvetica"}
set contents of contents of textobj to "This is text"
end tell
end tell
One thing I've found with Photoshop scripting - and perhaps this has improved somewhat, it's been 2 years since my last heavy work - is that the _javascript_ interface can be both much faster and supports more of the application. My last big project, in CS4, I routinely used the Script Events Listener plugin to "record" my actions in _javascript_, and then used those samples as the basis for building more generic _javascript_ handlers; I then wrapped the _javascript_ in AppleScript handlers which ran the _javascript_ in Photoshop via the "do _javascript_" method. On some scripts this sped things up enormously - I was using the AppleScript as a wrapper around the _javascript_, not communicating with Photoshop using its AppleScript interface.
It looks like you got a big improvement there though, and perhaps my advice is dated.
Cheers,
Roger |