Re: Set current document in Photoshop CS3
Re: Set current document in Photoshop CS3
- Subject: Re: Set current document in Photoshop CS3
- From: "Fleisher, Ken" <email@hidden>
- Date: Mon, 01 Feb 2010 10:09:52 -0500
- Thread-topic: Set current document in Photoshop CS3
Title: Re: Set current document in Photoshop CS3
Why is it that I can work on troubleshooting something for a week, give up and and finally post my question to this list, and then only minutes after I find the answer!?!
It turns out that all I needed was parentheses:
repeat until (document (name of doc20) exists)
I had the right idea that the script was moving too fast and trying to use the document before it was created, but my fix neglected the parentheses, which was unusual because everyplace else in the script I used “document (name of xxx)” with the parentheses!
Oh well, sorry to trouble you.
Ken
On 2/1/10 10:00 AM, "Ken Fleisher" <email@hidden> wrote:
Hello. I am having trouble with scripting Photoshop. I am using the following code to create a new document and then do actions on it:
tell application "Adobe Photoshop CS3"
set curDoc to current document
tell curDoc
set doc20 to doc duplicate name rootName & "_20-OL.tif"
end tell
set current document to document (name of doc20)
tell doc20
-- code that works on doc20
Unfortunately, after Photoshop duplicates the document (and I know it works because I can see the new document with the new file name), Photoshop does not recognize that the document exists and I cannot make doc20 the current document. I have tried the following:
tell application "Adobe Photoshop CS3"
set curDoc to current document
tell curDoc
set doc20 to doc duplicate name rootName & "_20-OL.tif"
end tell
repeat until (document name of doc20 exists)
end repeat
log (exists document name of doc20)
set current document to document (name of doc20)
tell doc20
-- code that works on doc20
But I just get the following result, even though I know the document exists:
exists document "Adobe Photoshop CS3" of document "A-4630105_20-OL.tif"
false
The script actually works as long as I only have one image open to begin with, but it fails when I have two or more images open to begin with. I’m not sure why that makes a difference, but it does.
Any ideas on what I’m doing wrong or how to work around this? Thanks in advance for any help you can provide!
Ken
--
Ken Fleisher
Photographer
Imaging & Visual Services
National Gallery of Art
Washington, D.C.
Phone: (202) 712-7471
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden