Skip to main content
Participating Frequently
January 4, 2010
Question

how to use Selection.select()

  • January 4, 2010
  • 1 reply
  • 5849 views

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

array of number
, with the aditional description:

Selects the specified region.
The region parameter is an
array of four coordinates,
[left, top, right, bottom].

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?)

This topic has been closed for replies.

1 reply

joc-wiAuthor
Participating Frequently
January 4, 2010

Actually, is there a more "productive" way to post feedback like this but the forums? Has anybody experience if the support can handle scripting-issues competently?

(never the less this should stay in the forums - I do guess that others will have the same problem.)

Chris Cox
Legend
January 4, 2010

Well, it would be more productive in the scripting forum instead of the SDK forum (which deals with C/C++ programming directly to the plugin API).

joc-wiAuthor
Participating Frequently
January 4, 2010

You are absolutly right (shame on me).

Are you able to move the topic?