Fit to Artwork Bounds - Illustrator CS5

Hello everyone,

Is there a way to Fit to Artwork Bounds in Illustrator CS5 with AppleScript?

Thanks for your help

Marth

Do you mean have the artboard to fit to the artwork bounds? Can you expand a bit?

Hello,

Thanks for your message.
Yes I’ve got an Artboard with a text-frame, and i want to resize the artboard to the size of the frame:

http://s17.postimage.org/6otq18rqn/Bildschirmfoto_2012_01_20_um_12_32_14.png

Is this possible with AppleScript?

I’ve just done a quick (unsuccessful test) and a bit of googlng. I found this:

http://forums.adobe.com/thread/287731

which says it is not possible.

You could do it by getting the artwork bounds as a measurement, creating a new document with those bounds and then copying and pasting the artwork.

Welcome to the painful world of applescripting Illustrator!

If your text frame was on the first artboard then.

tell application "Adobe Illustrator"
	tell the current document
		set vb to visible bounds of first text frame
		set artboard rectangle of first artboard to vb
	end tell
end tell

The posted link relates to Illustrator Pre-CS4. After which artboards were added and these are resizable the old style document was NOT.

Thank You very much for your help.

It works great:



tell application "Adobe Illustrator"
	tell document 1
		set theGroup to make new group item with properties {group item:every text frame}
		move every text frame to theGroup
		move every path item to theGroup
		set selection to theGroup
		set vb to visible bounds of selection
		set artboard rectangle of first artboard to vb
	end tell
	
end tell


Marth, where ever possible I avoid using selections. So you could trim to.

tell application "Adobe Illustrator"
	tell document 1
		set theGroup to make new group item with properties {group item:every text frame}
		move every text frame to theGroup
		move every path item to theGroup
		set artboard rectangle of first artboard to visible bounds of theGroup
	end tell
end tell

Thank You Very much Mark!

It works:



tell application "Adobe Illustrator"
	tell document 1
		set theGroup to make new group item with properties {group item:every text frame}
		move every text frame to theGroup
		move every path item to theGroup
		set theBounds to visible bounds of theGroup
		set artboard rectangle of first artboard to theBounds
	end tell
end tell

For posterity

The above method often ‘fills in’ outlined text with black, but the following method is simpler, and does not ‘fill in’ outlined text. The ‘+82’ allows for text boxes placed above the artboard.

Regards

Santa


tell document 1
						selectobjectsonactiveartboard
						set theBounds to visible bounds of selection
						set item 2 of theBounds to (item 2 of theBounds) + 82
						set artboard rectangle of first artboard to theBounds
					end tell

Model: Late 2014 retina i7, Yosemite
AppleScript: 2.4
Browser: Safari 600.2.5
Operating System: Mac OS X (10.10)