OmniGraffle Animation Script

Hey All,

Wanted to contribute some work I’d done in OmniJS to allow a user to build a sort of ‘animation’ out of complex OmniGraffle files. You have to structure your Graffle to use a layer as an animation frame, since at it’s core all it’s doing is turning one layer on and the previous one off. I’ve created a plugin for it, so paste this into “Animate.omnijs” in your Plugins folder and you should be able to set the following parameters by clicking “Animate”:

  • Delay - In Seconds, how long between steps
    *.Step Size - How many layers to increment (useful if you have a layer of description you want to increment alongside the graph layers)

I hope this helps!
/{
“type”: “action”
}
/

 function sleep(x,delay,stepSize) {
 	Timer.once(delay, function(timer){
		continueExecution(x,delay,stepSize);
 	});
 }

 function continueExecution(x,delay,stepSize) {
     layerRef[layerSize-x].visible = false;
     y=1;
     while(y<=stepSize) { layerRef[(layerSize-y)-x].visible = true; y++; }
     x+=stepSize;
     try {
     	if(x==layerSize){ throw new Error("Done."); }
     	sleep(x,delay,stepSize);
     }
     catch(e) {
     }
 }

 function reset() {
     x=layerSize;
     while(x>=0) { layerRef[x].visible = false; x--; }
 }

 var _ = function() {

var action = new PlugIn.Action(function(selection) {
	layerRef = document.windows[0].selection.canvas.layers;
	layerSize = layerRef.length-2; //Legend never goes off, and count is +1 of total.
	delayForm = new Form();
	delayInput = new Form.Field.String("delay", "Delay", "3");
	stepInput = new Form.Field.String("step", "Step Size", "2");
	delayForm.addField(delayInput);
	delayForm.addField(stepInput);
	prompt = "Delay Time & Step";
	title = "OK";
	formPromise = delayForm.show(prompt,title);
	formPromise.then(function (form){
    	reset();
		layerRef[layerSize].visible = true;
		layerRef[layerSize-1].visible = true;
		sleep(1,Number(form.values['delay']),Number(form.values['step']));
	})
});
    
return action;
 }();
 _;