This is the website of an IT geek, technologist, freelance writer, photographer, musician, rock climber, classic mini enthusiast, iPad and Mac zealot.
You have been warned.
Drawing a Number Square with Omnigraffle and AppleScript
This weekend, my daughter had some homework to do using a 10x10 number grid. But there wasn't one in her homework pack. I decided to make one for her. I'm not one for doing work manually when we can get a computer to do it, so I wrote an AppleScript to get Omnigraffle to create one. Here it is.
-- Main --
draw_it()
-- Functions --
on draw_it()
set basex to 10
set basey to 10
set squaresize to 50
repeat with y from 0 to 9
set itemy to basey + ((y) * squaresize)
repeat with x from 1 to 10
set theNumber to (y * 10) + x as text
set itemx to basex + ((x - 1) * squaresize)
tell application "OmniGraffle Professional 5"
tell canvas of front window
set MYSQUARE to (make new shape at end of graphics with properties {size:{squaresize, squaresize}, origin:{itemx, itemy}, text:{text:theNumber, alignment:center}})
end tell
end tell
end repeat
end repeat
return 0
end draw_it
- Log in to post comments


Recent comments