photshop script error

Discuss Moho bugs (or suspected bugs) with other users. To report bugs to Smith Micro, please visit support.smithmicro.com

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
knunk
Posts: 153
Joined: Thu Aug 05, 2004 7:18 am

photshop script error

Post by knunk »

Hi Guys
Im trying to export a psd to AS using the provided script but I get this error message....

error 8: syntax error
line:4
->#target photoshop

Im using CS on Win2000

many thanks for any help
Patmals
Posts: 551
Joined: Tue Aug 08, 2006 7:19 am
Location: Nagoya-shi, Japan

Post by Patmals »

Hi Knunk,

I was getting the same error so please look at my post in the scripting forum here:

http://www.lostmarble.com/forum/viewtopic.php?t=5378
User avatar
knunk
Posts: 153
Joined: Thu Aug 05, 2004 7:18 am

Post by knunk »

Great. Many thanks Patmals, I'll give it a try.
Patmals
Posts: 551
Joined: Tue Aug 08, 2006 7:19 am
Location: Nagoya-shi, Japan

Post by Patmals »

knunk wrote:Great. Many thanks Patmals, I'll give it a try.
Good luck!
User avatar
knunk
Posts: 153
Joined: Thu Aug 05, 2004 7:18 am

Post by knunk »

Hi
I've deleted the lines "#target photoshop" and "app.bringToFront();".
It seemed to work out fine. I tried to open it in AS but the file didn't have the.anme extension. So I opened it with AS and got this error.
"read error at line 6.include files C:\documents and settings\Mike Clifton\my documents\develop\lm_tree\lib_moho\mohodoc.cpp,line299."

It'd be great If i could get this working


Any ideas anyone?

Many thanks
Patmals
Posts: 551
Joined: Tue Aug 08, 2006 7:19 am
Location: Nagoya-shi, Japan

Post by Patmals »

Hi again Knunk,

I just tried it again. and i got the same error message..
and as you said, i needed to add the extension .anme to the file..

hmm..
User avatar
relik
Posts: 34
Joined: Wed Sep 13, 2006 3:52 pm
Location: Houston, TX, USA
Contact:

Post by relik »

The file header being written into the script is calling an external routine, that in turn has a bad hardcoded path to a local library on the programmer's hard drive.

That is, as far as I can determine the problem is not in the script but in the Anime Studio code modules-it's a "true" bug, and can only be fixed by replacing that module with a corrected version.

Major malfunction, guys. Let's get on this soon. -R
User avatar
knunk
Posts: 153
Joined: Thu Aug 05, 2004 7:18 am

Post by knunk »

no idea what you just said but it sounds cool to me. :)
I've not actually used AS on a show yet but have something coming up before Christmas I'd like to try it on. This plug would make that way easyer. Fingers crossed someone can make it work.

Many thanks..
User avatar
relik
Posts: 34
Joined: Wed Sep 13, 2006 3:52 pm
Location: Houston, TX, USA
Contact:

Post by relik »

Actually, after playing with it a bit more, I've located the problem. It is in the script, even though the error it is raising would seem to indicate a somewhat less than elegant substructure in the code.

To put it in plain language, the script writes out the information needed to open the file in Anime Studio to a text type document. The problem is that the dimensions of the original file are being passed in as inches instead of pixels, and AS can't deal with that.

It looks to me like the method the programmer used to do the conversion from inches to pixels is not supported in the CS version of Photoshop-only in CS2 (CS2 users say the script works).

In theory a more "universal" approach would be to take the inch values and multiply them by the resolution, which should give you pixels. I have yet to test it, but if it resolves the problem I'll post the relevant code changes here.

However there is a manual fix to the anme file you create with the script that will let you open it.

Run the script as discussed above creating an anme type of file. On the PC, right click and choose "Open with" and Wordpad or Notepad. (Don't remember how to get a file to open with the text editor on a Mac, but I'm sure the Mac guys will know how already).

Look for the line:

Code: Select all

### static values
dimensions XXXXXXXX YYYYYYYYY
Where X and Y represent a numeric value. These are likely to be in decimal form, i.e. 10.222222227 8.99999996 or something to that effect. It's pretty obvious though, that is doesn't represent pixels.

Change these values to either the actual pixel depth of your original Photoshop image or the dimensions in pixels you want your animation to be.

The first number is width. The second is height. It's a single standard space between them.

Save the file and close it. You will be able to open it in Anime Studio with no problems.

Will let you know if I can get an equation that gives the proper value out of the script. -R
User avatar
relik
Posts: 34
Joined: Wed Sep 13, 2006 3:52 pm
Location: Houston, TX, USA
Contact:

EVEN SHORTER ANSWER

Post by relik »

Before running the script, in Photoshop Preferences> Units and Rulers, set units to Pixels for Rulers and Type. Run the script. Problem gone. -R
User avatar
relik
Posts: 34
Joined: Wed Sep 13, 2006 3:52 pm
Location: Houston, TX, USA
Contact:

Post by relik »

I have modified the script to automate the process of switching the internal units to pixels for compatibility with Photoshop CS, as well as setting the preferences back to where they were for the application after the conversion of the file.

I'm not entirely sure of the legality of uploading the changed script though, since it shipped with the software, and is someone else's work.

If a mod can chime in and let me know what's acceptable I'll upload it for further testing/use.

In the meantime, if anyone is inclined to fix your own, you can find the exact code I used in the Javascript Reference for Photoshop CS on page 131 and 132 (as they are numbered in the manual-in the Acrobat reader they will be pages 137 and 138). Note that you don't need to include the code to turn off dialogs (in fact you don't want to).

You would insert the code to save the preferences and then change them after the line:

app.activeDocument = app.documents[docName];.

You would then need to insert the code to change them back to saved after the line:

alert("Export Layers To Anime Studio was successful.");

If you're comfortable at scripting, then you should have no prob figuring out the fix. My apologies to Mr. Clifton if I've said too much.

If you aren't inclined to script the preference change, then just remember to change your preferences to Pixels manually before you run the script provided. -R
User avatar
relik
Posts: 34
Joined: Wed Sep 13, 2006 3:52 pm
Location: Houston, TX, USA
Contact:

Post by relik »

One other thing in "doing it yourself". Be sure to remark out the lines

width.convert ("px")

and

height.convert ("px")

in the javascript file. These are the unsupported commands in Photoshop CS version 1. -R
Patmals
Posts: 551
Joined: Tue Aug 08, 2006 7:19 am
Location: Nagoya-shi, Japan

Post by Patmals »

Thank you very much for your information, Relik!

I will give it a go!

I'm a little mystified why some (most?) people do not get this problem..hmm

Thank you anway!! Well investigated!
User avatar
relik
Posts: 34
Joined: Wed Sep 13, 2006 3:52 pm
Location: Houston, TX, USA
Contact:

Post by relik »

The command "width.convert ("px")" and the one for height does not appear to be supported by the javascript engine in Photoshop CS. These appear to be only valid in CS2.

What is generating the error after the #target photoshop lines is removed is actually the Anime Studio program, trying to read the inches value that didn't get converted out of Photoshop properly. Since CS2 converts the values to pixels, what gets written to the anme file is what Anime Studio is expecting-no errors.

As I said, just setting your prefs to use pixels before running the script will solve the problem with the dimension error.

Not sure what is causing that first error. -R
Thunderone
Posts: 16
Joined: Sun Sep 17, 2006 6:15 pm
Location: México
Contact:

Post by Thunderone »

Hi relik, In the Forums of Anime Studio too, GREAT!, regards!.

And when fixed the problem of this script?, or maybe some action or script for Gimp or Corel Photopaint Pro too, please?.
-No es el lápiz, si no lo que hagas con él.-

- It's not the pencil, it's what you do with it!.-
Post Reply