Illustrator and text properties

I’m a newbie trying to learn this fine art. I am able to create a new text art item in illustrator but what is the format for setting properties like font and size.

This is what i have

set myName to make new text art item in current document with properties {position:{379, 735}, «class pCNT»:"starfox"}

Now how would I add font choice and size to this? Is there a strict format of character use and order when listing the properties for type?

Also I didnt originally write this script with “class pCNT” in it. Did Script Editor alter this?

Here are some examples (works with CS):

set text font of text range of myName to text font "Times-Bold"
set properties of text range of myName to {size:11}
set redColor to {class:CMYK color info, cyan:20, magenta:90, yellow:45, black:20}
set fill color of text range of myName to redColor
set size of text range of myName to 48
set y to properties of text range of myName

A caveat: You should check if the text font exists before assigning it to the text. Use a try block like:

try
	set theFont to text font "Times-Bold"
on error
	set theFont to text font "Myriad-Roman"
end try

set text font of text range of myName to theFont

Also, you can replace ‘«class pCNT»’ with the term ‘contents’.

WOW I never would of thought to do it that way! I thought all of the properties would be listed after creating the vairable fo just the text.

what is this line for?

set properties of text range of myName to {size:11}

Also can you point me in some direction to understanding how to interpret ill’s dictionary?

Thanks again :smiley:

That’s just another example method of setting properties of text. It could also have been accomplished with the other form, i.e.

set size of text range of myName to 11

Do you have the Illustrator Scripting Guide?
http://partners.adobe.com/public/developer/en/illustrator/sdk/IllustratorScriptingGuide.pdf

Other than that, my method is a boat load of trial and error. I usually have a test doc open with objects I’m interested in manipulating, the dictionary open and viewing the description of the target object. If I’m just starting out and don’t know how to change things, I get the properties of the target object and look for a property that might do what I want it to do, or at least point to another object I can manipulate to get what I want. Rinse and repeat.

starfox25,

You can also do this,

tell application "Illustrator CS"
	activate
	set docref to make new document with properties {height:864, width:864}
	set thisDoc to current document
	make new spot in thisDoc with properties {name:"myBlue", color:{cyan:100, magenta:80, yellow:30, black:5}}
-- this makes a character style that can be used on any number of text frames
	make new character style in thisDoc with properties {name:"style1"}
	set the size of character style "style1" of thisDoc to 8
	tell thisDoc
		set the fill color of character style "style1" of thisDoc to {class:spot color info, tint:100, spot:spot "myBlue"}
	end tell
	set the text font of character style "style1" of thisDoc to text font "Helvetica"
	set textref to make new text frame in thisDoc with properties {name:"txt1", contents:"test test test"}

	apply character style character style "style1" of thisDoc to text range of text frame "txt1" of thisDoc
end tel

However, I don’t know if it is a bug in CS or not, but when I make a spot color it does not set itself to an actual spot color. It still has cmyk color values and I have to either make a document that will open with the spot in it already or change it within the document made. :frowning:

PreTech