Skip to main content
Known Participant
February 2, 2017
Answered

Need help diagnosing one line of code

  • February 2, 2017
  • 2 replies
  • 547 views

I and using javascript

I want to set a rectangular selection.

both of these throw an error and i can't figure why;

app.activeDocument.selection.select([3111.62,936.63,5300.89,4025]);

or

var coverRegion = [3111.62,936.63,5300.89,4025]

app.activeDocument.selection.select(coverRegion);

if I change this to crop it works though. According to the javascript reference guide it the same kind of array of coordinates (left, top, right bottom)

app.activeDocument.crop([3111.62,936.63,5300.89,4025]);

I have tested this as just a single line of code in it's own document and still get "Error 1220: Illegal Argument"

I'm pulling my hair out here.

This topic has been closed for replies.
Correct answer Kukurykus

activeDocument.selection.select([[3111.62, 936.63], [5300.89, 936.63], [5300.89, 4025], [3111.62, 4025]])

2 replies

Known Participant
February 2, 2017

I just found the answer but this make s it m​uch more clear so thank you.

  1. activeDocument.selection.select([[3111.62, 936.63], [5300.89, 936.63], [5300.89, 4025], [3111.62, 4025]]) 

translated:

  1. activeDocument.selection.select([[LEFT, TOP], [RIGHT, TOP], [RIGHT, BOTTOM], [LEFT, BOTTOM]]) 
Kukurykus
Legend
February 3, 2017

function rec(l, t, r, b) {activeDocument.selection.select([[l, t], [r, t], [r, b], [l, b]])}

rec(3111.62, 936.63, 5300.89, 4025)

Kukurykus
KukurykusCorrect answer
Legend
February 2, 2017

activeDocument.selection.select([[3111.62, 936.63], [5300.89, 936.63], [5300.89, 4025], [3111.62, 4025]])