Apply a brush from a library

Is it possible to apply a brush from a brush library (primarily not open) in Illustrator CS? (I can have the library open if need be).
This code works well, but only if the brush resides in the default brush palette. The brush I am using will unfortunately have to exist in a specific brush library.

apply brush 1 of document 1 to theSelection

I don’t know if this is the most simple way to accomplish the task but it works. First you can choose the brush file from within your Illustrator CS folder. From there it is a bunch of copy/paste to get the brush you want applied. I am guessing the placement of the selection of the final paste command may be an issue because it defaults to the center of the screen.

Anyways, I hope this helps…

set theBrushFile to "Macintosh HD:Applications:Adobe Illustrator CS2:Presets.localized:Brushes.localized:Borders.localized:Borders_Dashed.ai"
tell application "Adobe Illustrator"
	activate
	copy selection
	delete selection
	open file theBrushFile
	paste
	apply brush 7 of document 1 to selection
	copy selection
	delete selection
	close document 1 saving no
	paste
end tell

Matt

Matt, this is GREAT!
Your solution is accounting for what I asked. The position of the pasting would not be an issue if “Paste in Front” existed in AS. I am sure there is a way to grab a location of an object and then move the final pasted object to that spot. I will be looking into that.

Thanks a bunch.
-jeff

Using this script in conjunction with Quickeys worked almost perfectly. I split the script in two. So the “Paste in Fronts” were performed by additional Quickey steps. Sure, there may be a very slim chance of a stacking order issue. But for my use, the object that is copied,deleted, and pasted will almost always be on the topmost stacking level. But the X,Y, is now dead on since I always use the same document size.

Thanks again, your advice really helped me out.
-jeff

Hey Jeff,

Glad I could help.

M