picture home | art | events | music | rack extensions | downloads | pixel blog | qt_tools

omino pixel blog

pixels, motion, and scripting
david van brink // Mon 2008.12.15 06:59 // {extendscript illustrator}

Two Illustrator Scripts

Here’s a pair of Illustrator scripts I’ve had up for a while, but this is the first time I’ve posted examples. Also, Javier Enciso of www.formaestudio.com in Uruguay spotted a bug in the triangle script, which is now fixed.

Both available at http://omino.com/sw/ominoAdobeScriptsSuite/.

Circular Gauge (circularGauge.jsx)

circularGauge.jpg

This script draws numbers and tick-marks to resemble a circular gauge. It lands up in its own layer, and the text and ticks are in their own group, ready for tweaking. I use it to make pretty machines in Second Life. A bit of emboss and off you go.

Triangle By Sides (triangleBySides.jsx)

triangleBySides.jpg

I can’t remember what I needed this for, but it was exactly what I needed at the time. Self explanatory!

oh, i dont know. what do you think?


david van brink // Thu 2008.10.2 22:41 // {after effects extendscript}

Handy Scripts

Tasks Beget Subtasks

That’s always how it is, I’m trying to do something, but then a new jig or tool is needed along the way.

Just lately I’m finally “remastering” some ancient (80’s) video of my own. Captured it off VHS video in 2004, been sitting on my hard disk since then. Tragically, the capture introduced some awful drift between audio and video. I probably used iMovie for a 30 minute capture, just like they say not to.

Why am I using AE for this? Because I haven’t upgraded the stupid final cut pro to the stupid expensive intel version, because I stupidly missed the $50 upgrade special window.

And as long as I’m complaining: How come AE doesn’t have some fine-numeric control for time-bumping the layers?? Ok. So it goes.

But meanwhile, I need some fine-control to shift the layers left and right.

I’m thinking, should I write a script for this? But something tickles my memory. A yes, this is just the sort of thing that can be found on Jeff Almasol’s most excellent redefinery blog and scripts collection. Many useful scripts there; solid work-a-day workflow helpers. Also, exquisitely coded. Excellent style, thrilling examples, and so forth.

Happily, redefinery’s rd:scooter was just the tool to nudge things back into place!

After nudging around my 30 minute audio and video layers, I wanted to snip out just the 2 minutes for the particular song-section. But the in- and out-points were far off to the left and right of my dinky 3 minute comp. So I wrote a script panel for this last bit:

I tried to keep it nice and narrow, to fit in easily with the other built-in palettes. It’s ugly, but then it worked so I stopped coding & used it. Click here or on the picture to get it from my scripts collection.

After Effects Scripting Bug

Ah yes, there’s a bug in After Effects CS3’s scripting that I came across. If you set layer.inPoint = t; it also sets the outpoint! My workaround was like so:

	// bug? setting in seems to corrupt out. save and fix.
	var outPoint = layer.outPoint;
	layer.inPoint = myComp.time;
	layer.outPoint = outPoint;

This workaround should be safe even after they fix the scripting bug. (Not sure where to report Adobe bugs…)

So… Then What?

And lastly, some excerpts from the product of this endeavor: Vintage 1986-era animation loops done with Macromind’s Videoworks ! Orchestrated with my own long-forgotten music software, “Synthestra” (MIDI) and P-Drum (sample player), both for the Apple II, distributed by Dan Retzinger’s company, Decillionix.

Check it out. 30 seconds of techno-stalgia.

C5zZ-9Impnk

click for
http://www.youtube.com/v/C5zZ-9Impnk&hl=en&fs=1&rel=0

oh, i dont know. what do you think?


david van brink // Sun 2008.09.21 19:35 // {after effects extendscript photoshop}

Omino Dialog Maker for ExtendScript

ExtendScript

My favorite Adobe applications are all scriptable. They use a scripting language called ExtendScript. I think it’s pure and compliant JavaScript (aka EcmaScript)… if it has any deviations, it’s in some subtle fashion that hasn’t affected me.

One thing you frequently need in a script is a means to gather input choices, so the script can be flexible. I rolled something up that handles this for many simple situations. I call it the Omino Dialog Maker. It’s a software library that lets you bring up an input dialog with just a couple of lines of code. It is mostly about 2 years old now, works pretty well.

Omino Dialog Maker

Here’s a simple example of a dialog made with the Omino Dialog Maker.

And here’s the code to produce it:

#include "ominoDialogMaker.jsx"

var omd = newOminoDialog("Example Omino Dialog");

omd.number("a number","n",88.21);
omd.string("a string","s","your name here");
var result = omd.run();

if(result == null)
	alert("Cancelled\nYou clicked \"cancel\".");
else
	alert("n is " + result.n + ", and s is \"" + result.s + "\"");

That’s pretty handy, isn’t it? As you can see, omd.run() populates a result variable with the contents of the dialog.

I admit it: tt’s not the best possible dialog and layout. It’s a little clunky looking. But it gets the job done, lets me type in a few numbers and set meat of the script to work.

More UI Elements

Here’s a dialog which shows the various UI elements supported by Omino Dialogs:

And, here’s the code which produced it:

#include "ominoDialogMaker.jsx"
function go()
{
	// setting up a dialog is easy. you can add entries for basic types of
	// string and number, and checkbox and radio buttons, and the
	// dialog is presented reasonably, with very little work.

	var omd = newOminoDialog("Example Omino Dialog");

	omd.boxedText(5,"This is an example of an Omino Dialog. It runs \n"
		+ "with After Effects, Illustrator, and Photoshop, or just in the\n"
		+ "ExtendScript toolkit itself. It can handle simple parameter types."
		+ " (Running in " + app.name + " v" + app.version + ")"
	);
	omd.number("a number","n",15.7);
	omd.string("a string","s","a text value");
	omd.separator();
	omd.sectionLabel("basics");
	omd.checkbox("a checkbox","x",true,"subtitle");
	omd.menu("a menu","menu","cherries",["apples","bananas","cherries","dates","figs"]);
	omd.radioButtons("Choose One","r","red",["red","maroon","scarlet","crimson"]);
	omd.separator();
	omd.sectionLabel("files");
	omd.openFile("a file","jpgFileName","foo.jpg","Choose a JPEG File",".jpg");
	omd.selectFolder("a folder","folderName","/tmp","Choose a folder");
	omd.saveFile("save as","gifFileName","foo.gif","Save as GIF",".gif");s

	// when we "run" the dialog, we get back a result variable.
	// if you hit CANCEL, then the result is null.
	// if you hit OK, then the values are populated into the result.

	// note: you can kill photoshop by running the dialog from ExtendScript toolkit, then halting
	// the script with the dialog still up.

	var result = omd.run();

	if(result == null)
		alert("Cancelled\nYou clicked \"cancel\".");
	else
	{
		var s = "result from dialog:\n";
		for(var f in result)
			s += "   " + f + " := " + result[f] + "\n";
		alert(s);
	}
}
go();

If you’ve read this far, you’re hopefully asking, “Gee, where can I get the actual library?” Here’s the code, shown directly out of my source code repository. Download with the download button.

http://dvb.omino.com/src/adobe_scripts/omino_adobe_script_suite/src/shared/ominoDialogMaker.jsx in new window download http://dvb.omino.com/src/adobe_scripts/omino_adobe_script_suite/src/shared/ominoDialogMaker.jsx to file hide http://dvb.omino.com/src/adobe_scripts/omino_adobe_script_suite/src/shared/ominoDialogMaker.jsx

 

Trivia: UI Differences Across Adobe Applications

Omino Dialog Maker can be used for scripts in After Effects, Photoshop, and Illustrator, at least, and possibly other Adobe applications. I have noticed that the dialogs look slightly different in each of these apps! Not critically… For reference, here are screen shots from several.

12 comments
Austin Wallender // Mon 2008.09.22 09:549:54 am

This looks amazing. Can’t wait to try it out! Thanks for the hard work….

Justin Putney // Sun 2008.11.23 16:214:21 pm

Thanks a ton for posting, David! This is extremely useful. I used the Omino Dialog Maker code in my Merge Text for Illustrator extension:
http://ajarproductions.com/blog/2008/11/23/merge-text-extension-for-illustrator/

david van brink // Sun 2008.11.23 22:4710:47 pm

Yay! Glad you found it useful.

James Talmage // Sat 2008.11.29 08:298:29 am

David,
Thank you for sharing this much-needed script. I’ve just successfully modified one of my scripts which formerly relied upon three separate prompt() statements to obtain the user inputs needed for the script.

I have noticed one caveat, though, which I hope you can explain. In both my script modified to use Omino Dialog, and in your first sample script (the one which invokes a dialog with two inputs), if the user clicks Cancel, the alert appears as expected, but then Illustrator’s window minimizes, effectively “taking” the user to whatever OS or app window was previously active.

Any ideas on that?

Again, thanks much for Omino Dialog.

Illustrator CS3
Windows Vista Basic

david van brink // Sat 2008.11.29 16:294:29 pm

Hi James — thanks for your note. I’ve only used it extensively on Mac OS X; I use After Effects on Windows a little but haven’t seen that symptom. Will investigate further…

Thanks for the bug report! Any further info very welcome.

Joel // Tue 2008.12.30 16:104:10 pm

Thanks so much for the scripts! HOWEVER, I’m wondering if you or anyone can advise as to what is causing my “Window does not have a constructor” error that prevents this from working? Illustrator refuses to instantiate a window for me (jerk!).
I’m using AI CS2 on a Mac running Tiger and I am clueless as to the source of my misery. Thanks!!!

david van brink // Tue 2008.12.30 21:569:56 pm

Joel… I’ve only used CS3 and CS4. It’s… probably a clue. :(

Dave Stewart // Fri 2009.04.10 07:297:29 am

Just checking your work out now. Great stuff!

I’m wondering why you don’t use proper JavaScript for creating your objects though? Why not just make newOminoDialog a OminoDialog object, and instantiate with the “new” keyword?

Do you need some help writing JavaScript prototypes?

Let me know if you do – it will tidy up the global space a LOT.

Cheers,
Dave

david van brink // Sat 2009.04.11 17:005:00 pm

^^^ Dave, thanks!

If I understand rightly, the “real object-ness” is orthogonal to the global namespace pollution. That is, I could (and should) allow “new OminoDialog()” to work, and depending where the functions live will be in or out of the global name space.

But the real answer to your question is: When I first wrote this, I didn’t know about either of those issues. Version 2!

Dave Stewart // Sun 2009.04.12 07:367:36 am

Hey David,

Ah, yes, I understand! JavaScript is a bit of a dark horse – there’s a lot of power hidden away in there!

Well, as it happens I got all curious ysterday and decided to whip something OOP up yesterday, and I’m nearly done. I may put it on hold for a week or two as I have other projects pressing, but I’ll happily send it your way so you can see what it’s all about when I’ve finished.

Some nice ideas in your work, especially saving the values in once central place.

Cheers for now,
Dave

heavyboots // Mon 2009.05.4 16:014:01 pm

Wow, this is just the ticket. Barely stumbling around in JS (I usually use Applescript) so this looks like it will ease the pain a lot. Thanks!

PS: FWIW, I immediately hacked the buttons over to the right side as they just looked too weird on the left.

okRect.left = D_DIALOG_WIDTH – D_MARGIN – D_BUTTONWIDTH;
okRect.top = y;
okRect.right = okRect.left + D_BUTTONWIDTH;
okRect.bottom = okRect.top + D_CONTROLHEIGHT;

cancelRect.left = okRect.left – D_MARGIN – D_MARGIN – D_BUTTONWIDTH;
cancelRect.top = y;
cancelRect.right = cancelRect.left + D_BUTTONWIDTH;
cancelRect.bottom = cancelRect.top + D_CONTROLHEIGHT;

david van brink // Mon 2009.05.4 18:416:41 pm

!! you’re so right about the button placement! Always interested to see what you’re making with it.

oh, i dont know. what do you think?



0.0494s
(c) 2003-2013 omino.com / contact poly@omino.com