Skip to main content
Inspiring
July 16, 2018
Answered

how to select with intersection?

  • July 16, 2018
  • 2 replies
  • 1315 views

I don't understand how to make an intersection selection.

I tried the following code with a 600 x 800 pixels document with a simple background layer:

var originalRulerUnits = app.preferences.rulerUnits; // valeur actuelle Ruler

app.preferences.rulerUnits = Units.PIXELS;

var originalTypeUnits = app.preferences.typeUnits; // valeur actuelle prefs

app.preferences.typeUnits = TypeUnits.PIXELS;

app.activeDocument.selection.selectAll();

// trying to select a 10px "frame"

app.activeDocument.selection.select([[10, 10], [10, 780], [580,780], [580, 10] ], SelectionType.INTERSECT);

No intersection is done, new selection replaces the existing one.

Thank you for your help.

This topic has been closed for replies.
Correct answer frmorel

r-bin  schrieb

And what result did you expect?

Well, hum... my bad, It was a language problem, I wanted to DIMINISH previous selection and it works fine.

activeDocument.selection.select([[10, 10], [10, 300], [300, 300], [300,10]], SelectionType.REPLACE);

activeDocument.selection.select([[20, 20], [20, 200], [200, 200], [200,20]], SelectionType.DIMINISH);

Sorry

2 replies

Legend
July 16, 2018

fredericm80874937

No intersection is done, new selection replaces the existing one.

And what result did you expect?


frmorelAuthorCorrect answer
Inspiring
July 17, 2018

r-bin  schrieb

And what result did you expect?

Well, hum... my bad, It was a language problem, I wanted to DIMINISH previous selection and it works fine.

activeDocument.selection.select([[10, 10], [10, 300], [300, 300], [300,10]], SelectionType.REPLACE);

activeDocument.selection.select([[20, 20], [20, 200], [200, 200], [200,20]], SelectionType.DIMINISH);

Sorry

Kukurykus
Legend
July 29, 2018

You should mark correct solution

Kukurykus
Legend
July 16, 2018

Use other selection instead of this line:

app.activeDocument.selection.selectAll();

like whatever that can be intersected:

activeDocument.selection.select([[0, 200], [50, 360], [970, 1260], [0, 500]], SelectionType.REPLACE)