Illustrator resize text box script - please help

Hi,

If anyone can help it would be really appreciated. I have a simple (I think…) script I urgently need for Illustrator. My files have several thousand text boxes whose contents have been replaced - and most now overflow since the replacement text is longer. Rather than clicking all the overflow symbols by hand, I came up with an idea - but since I can’t script and can’t find anything online, I need your help.

If there is any other automated way of doing this, feel free to suggest!

My idea:

  1. Go to first selected text box (assume there are MANY text boxes)
  2. Resize text box 150%
  3. Replace font size (because it is now bigger than before) with the original font size prior to resizing
  4. Change font color to Magenta (or some other color, this is so I can find these boxes quicker)
  5. Go to next text box and repeat step 2-5 until all selected text boxes have been resized

The reason I can’t write an action is because the text boxes have different size fonts in them, as well as applying these changes to all text boxes at once moves most of them far, far away from their original insertion points.

Any help or suggestions highly appreciated.

Regards,

Zlato

Hi Zlato

Not sure if this is exactly gonna work for you but it shouldn’t be a million miles away (fingers crossed!)

tell application "Illustrator CS"
	tell document 1
		set Tcount to count text frames
		repeat with i from 1 to Tcount
			tell text frame i
				set Tsize to size of text range
			end tell
			set Tkind to kind of text frame i
			if (Tkind = area text) then
				set CW to the width of text frame i
				set CH to the height of text frame i
				set width of text frame i to CW * 1.5
				set height of text frame i to CH * 1.5
				tell text frame i
					set size of text range to Tsize
					set fill color of text range to {class:CMYK color info, cyan:0, magenta:100, yellow:0, black:0}
				end tell
			end if
		end repeat
	end tell
end tell

Thanks!! It works:D

I had to change the area text in the script to path text, since apparently all the text boxes are on paths. You have just saved me from MANY hours of very tedious work. The script actually resizes all the text boxes… which statement should I add to only complete the resize on selected boxes?

Again, thanks a lot.

Regards,

Zlato

Not Sure? Really
There needs to be something about these particular boxes that you can reference in the script so you can tell the script to omit these from
whats getting resized etc…
otherwise it’ll just go thru each text box one at a time.
e.g. if the text was a different size in these particular boxes (say 14 point) you’d be able to tell the script to ignore any text frames that have text which is point size 14 but resize every other box that it finds that doesn’t have text which is 14 point…

cheers

Thanks. I think I’ll apply a different color to the text boxes that overflow, and put a conditional in the script.
Just checked, I have 53 different font sizes in the files… :slight_smile:

Regards,

Zlato

looks like others bet me to it but here’s mine anyhow its only slightly different



tell application "Adobe Illustrator"
	tell document 1
		set TheSelection to selection
		repeat with aBox in TheSelection
			set theCount to count of characters in aBox
			
			-- get the size of fonts to so we can set the font sizes back after resizing the box
			set theFontSizes to size of characters of aBox
			
			-- resize
			set width of aBox to (width of aBox) * 1.5
			set height of aBox to (height of aBox) * 1.5
			
			-- set the fonts back to the original size we doe each one individually incasse multiple font sizes where used
			repeat with i from 1 to theCount
				set size of character i of aBox to (item i of theFontSizes)
			end repeat
			
			-- change the color to Red so we can readily keep track of what has been done and what has not  
			set fill color of characters of text of aBox to {class:CMYK color info, cyan:0.0, magenta:100.0, yellow:100.0, black:0.0}
		end repeat
	end tell
end tell

Don’t worry, I really appreciate your help as well. As it now looks I’ll be making a combined script with bits of both suggestions. It’s interesting in itself how there are so many different ways of making a script…

Again, thanks to both.

Regards,

Jure