Adobe illustrator CS scriptsing problem.

So i dived into AppleScripting because I have a few hundred stills I ran a Live Trace Batch on. But since Bridge does not allow you to change the Art Board properties before the batch. I need to program a script that can go in and change the Art Board properties. I was hoping to use Automator with Applescript to Batch resize all my stills. So far this is what I have written for the Applescript.

tell application “Adobe Illustrator”
set properties to {width:640, height:480}

end tell
end

I thought this would be straight up easy but i got an error.

set properties to {width:640, height:480}
	"Adobe Illustrator CS2 got an error: Can't set properties to {width:640, height:480}."

So it seems I can’t set the properties on the art board. Any suggestions or clues or anything would be extremely helpful.

:confused:

You need to make sure that you define which type of units that you are using. Illustrator probably thinks that you are trying to make a document 640 inches by 480 inches instead of pixels.

I have no clue as to how to go about telling the script to do Pixels as the unit for the document. I have been looking at the Adobe Illustrator CS2 - AppleScript Guide. Which is how i was able to write this script but it covers every other unit for a document.

I would also like to add that I wrote a script to make a new document.

tell application “Adobe Illustrator”
if (document 1 exists) then
make document with properties {width:1920, height:1080}

end if

end tell

Which works fine and I didn’t need to add the units I was using. What I don’t understand is why it wont change the Artboard properties of an existing document that I have opened.

A quick test shows that when you create a new document it uses the units that were used with the last document that was created. It looks like the Units property of a document is read only and cannot be changes by a script. Also the document size (height and width) do not change when the ruler units is changes, instead it uses the same units that were used when the document was created. Looking further at the dictionary Height and Width of a document are also read only. It doesn’t make sense to be why they would have these as read only properties, especially since they are not in InDesign or PhotoShop. I would go to Adobe’s Forums for scripting and see if there is anything there on it and if you can place a suggestion for future features http://www.adobeforums.com/cgi-bin/webx?14@@.ee6b324.

Sorry I couldn’t be further help.

Jerome

I would like to first and foremost thank you for taking the time in helping me out. I have taken your advice and looked at the url. I had no luck in finding anyone with a seemlier problem. But I did post my thoughts on the problem I had and future solutions.

:cool:

The best way I can see to do this would be to open the document you want and then create a new document with the size you want. The units that Illustrator uses (as least CS1) is points and originates from the bottom left corner. So if you said:

tell application "Illustrator CS"
set newDoc to make new document with properties {height:640, width:480}
end tell

you would end up with a document 640 points high by 480 points wide. (There are 72 points per inch). I think that the units do not matter to Illustrator. I believe it always uses points. As far as pixels, I’m not sure if Illustrator can do pixels. If you can get the dimensions of the image from an image editor (or know what the dimensions are) you can use Illustrator to make a new document of that size. However, as Jerome said, the document, once made, cannot be changed - the height and width are read only at that point.

PreTech

PS: this was from the Ill CS guide:

also from the guide

ruler units read only and can be of unknown, inches, centimeters, points, picas, milimeters, or qs.

I found the answer to my problem with Adobe Bridge. It seems there is a work around for changing the size of a Batch render. So this means i don’t need to make an Apple Script. But I would like to thank Jerome and ProTech for the help.

:smiley:

Well put PreTech. From my testing if you make a document using pixels the next document will hold that setting. Playing around with a document, and something that I should have realized right away, the pixel measure ment is screen resolution of 72 dpi, and since points are 1/72" that make one point 72 dpi, so points and pixels in Illustrator are essentially the same measurement system.

See page 55 of AICS2-AppleScriptGuide.pdf for units of measure. Points are always used and a conversion chart is there. Both the units of measure and the document page size as r/o are both posted in adobe’s scripting forum as feature requests. Having to do a repetative copy an paste for all the math in this app kind of goes against the grain of scripting im trying to reduce the repertition in my work flow not increase it. (rant over.) This is the sort of thing that bugs me.

tell application "Illustrator CS"
	set docRef to the current document
	make new rectangle in layer "Layer 1" of docRef with properties ¬
		{fill color:{cyan:0, magenta:100, yellow:100.0, black:0.0}, stroked:false, position:{5 * 2.834645, 292 * 2.834645}, width:10 * 2.834645, height:10 * 2.834645}
end tell