664 words on earthlingsoft
As a user I always like it when applications are scriptable as it makes applications more useful in the sense that you it lets you use them in ways the developer hasn’t anticipated. As a programmer I am thus happy that Cocoa makes it rather easy to add basic scriptability to your application. In fact, for accessing and setting data in documents all you need are KVC complicant classes inside your documents and a scripting definition XML file.
That could be considered a trivial thing and I really wonder why so many applications ship without this kind of basic AppleScript support. I sometimes suspect that developers are just not aware of the possibility (which in turn makes me wonder how developers can not be aware of that). It is true that Apple’s documentation for AppleScript support used to be rather bad and that figuring out how to implement it was hard (probably harder than the code needed to support it), but since Mac OS X.4 and the introduction of
sdef files things have been reasonably easy to do. In X.5 some of the remaining edges have been smoothened as well. And with tools like Sdef Editor even those technicalities are reasonably easy to handle.
As a consequence I added basic AppleScript support to Symmetries even though I didn’t see much use for it. But that’s exactly the point of scripting support: making it easy for people to do things I did not anticipate or consider worth the effort of implementing myself.
Recently Arthur asked about being able to reverse the steps of an animation which Symmetries plays. Symmetries totally isn’t made to do that. It’s a marginal feature which would make Symmetries’ ‘fun’ animation mode slightly useful. But implementing it with a nice GUI and everything would be a lot of effort. Yet, it’s a good idea: You see a nice shape in an animation which you want to keep, but due to its continuous movement it will be lost by the time you stop the animation. Hence, having a bit of history would be good.
As Symmetries’ files are quite small and quickly written, I started wondering whether I can write a simple script which records the steps of the animation reasonably smoothly by saving the current state to a file. It turned out that a few lines of script:
set f to choose folder
set outputfolder to POSIX path of f
tell application "Finder" to open f
tell application "Symmetries"
set n to 1
save first document in outputfolder & (time of (current date) as string) & "-" & (n as string) & ".symmetricpath"
set n to n + 1
… do the trick. Open the script in Script Editor, run it, select the folder the files should be stored into and then start the animation in Symmetries. The script will store the current state to the folder as quickly as it can and you can easily see the images in the Finder later on thanks to Quick Look.
You’ll have to hit ⌘-. in Script Editor to stop the script. And I wouldn’t let the script run too long because it creates loads of files somewhat rapidly.
It’s not particularly pretty but it may give a reasonable approximation to the desired feature with just a little effort. That’s what scripting is for.
The script download does not work. And pasting the code in the editor results in errors. Please help! Thanks.
Thanks for pointing this out. It looks like the file vanished. No idea how that happened. I restored it to its old place and the link should work now. HTH.
[Copy and Paste should work as well now – the smart quotes automatically inserted by the blogging software messed that up, it’s probably a good idea to keep such scripts non-smart-quoted.]
Received data seems to be invalid. The wanted file does probably not exist or the guys at last.fm changed something.