Today I wanted a minor script to create a selection. Should have gone easily via:
app.activeDocument.selection.select(...)
The Photoshop CS4 JavaScript Ref.pdf says the "select" method of the Selection Object has only one required paramter:
select(region[, type][, feather][, antiAlias])
So, this region is described as [quote]array of number[quote], with the aditional description:
[quote]Selects the specified region.
The region parameter is an
array of four coordinates,
[left, top, right, bottom].[/quote]
It took me two hours to figure out that "region" actually needs...
... an array of arrays!
Not even for of them. Not even defining something like " left, top, right, bottom ". Actually, it works like:
var A= Array(2, 2);
var B = Array(10,1);
var C = Array(2, 10);
var D = Array(10, 10);
var E = Array(14, 14);
var myRegion = Array(A, B, C, D, E);
app.activeDocument.selection.select(myRegion);
I feel like a fool when I have to justify why it took me two hours for what should have taken 2 minutes. I do a lot of scripting in Maya, and I love it. But when I script for Adobe Products, things like that happen far to often.
(Interestingly enough, the documentation claims that Document.selection is read-only. So how did I just change it?)