Skip to content

Instantly share code, notes, and snippets.

@k2052
Created February 14, 2012 07:18
Show Gist options
  • Save k2052/1824463 to your computer and use it in GitHub Desktop.
Save k2052/1824463 to your computer and use it in GitHub Desktop.
make sure to install rbappscript first. Then you'll need the MakeCustomShape action installed from here http://cl.ly/2x3Z2j3a2B0X292b1f1S. Theoretically that is it. Works for me, hopefully for you as well.
require 'rubygems'
require 'appscript'
# Make sure to open your apps first. Appscript can get ahead of itself and not wait for them to load so it will fail
# Set your dir with AI files and thats it
dirname = "/Users/kenerickson/testCSH"
ai = Appscript.app.by_id('com.adobe.illustrator')
ps = Appscript.app.by_id('com.adobe.photoshop')
# ps = Appscript.app("/Applications/Adobe Photoshop CS3/Adobe Photoshop CS3.app")
ps.activate()
ps.settings.ruler_units.set(:pixel_units)
ps.make(:new => :document, :with_properties => {
:name => 'bookworm is a genius',
:width => 800,
:height => 600
}
)
Dir["#{dirname}/**/**"].each do | thisfile |
ai.open(MacTypes::Alias.path(thisfile))
layers = ai.current_document.layers.get
layers.each do |layer|
layer.has_selected_artwork.set(true)
end
ai.copy()
ps.activate()
ps.paste()
ps.do_action('MakeCustomShape', {:from => 'MakeCustomShape'})
ai.current_document.close(:saving => :no)
end
ps.current_document.close(:saving => :no)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment