Creating stencils using JavaScript


I would like to write a script to automate creating stencils for Amazon Web Services architecture diagrams.

Amazon provides a set of icons (including EPS
images, which OmniGraffle supports). I would like to use JavaScript for Automation to create stencils for each grouping of icons (where each grouping matches a folder in the zip they provide), import EPS images into each stencil (EPS files in the respective folder), give each stencil a name matching its folder, give each icon a name matching its EPS file name, and layout the images automatically so they don’t overlap and are easy to view if someone looks at a complete stencil.

Here’s the folder structure with one folder expanded for reference.

I’m new to Apple’s JavaScript for Automation. I opened the OmniGraffle dictionary in the Script Editor hoping there would be some obvious methods I should be using to create a stencil, import images, align them, … but am not finding anything to be obvious.

Is what I’m trying to accomplish even possible? If so, does anyone have any pointers for me to get started?


Hey Justin.

I am trying to do exactly the same thing, but I don’t much care which language it’s in and I’m trying to import SVG (using OmniGraffle 7 betas). I found your post by googling for omnigraffle applescripting.

Any progress with this?

My ideal goal is a program that others can also use to generate a set of stencils from whatever the latest AWS icons are, i.e. walk the folder. Same as what you’re trying.

So, here’s what I think I know:

  1. Yes, this is possible!
  2. Worst case scenario: you have to convert to OmniGraffle native XML.
  3. (Assuming the basic format hasn’t changed too much in the last couple versions.)
  4. Best case: you can script it with AppleScript, and if need be call that from the language of your choosing (anything that can shell out, basically, so NodeJS should work).

I will be playing with this a bit and I’m pretty hopeful that I will make it work, though I admit my Graffle hacking mojo is very rusty.

If you want to compare notes feel free to look me up under this username on FB or GH.

cheers & good luck

– frosty

Thanks for the reply, frosty. No update on my end. I’m getting familiar with AppleScript and automating stuff in OmniPlan at the moment, but plan on coming back to this when I get time. I’d love to hear about any progress you make! :)

I’m so out of date here, I didn’t realize there is some kind of native Javascript support. But I’m still going to try to duke it out with AppleScript if I can.