• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
3

illustrator javascript code for selecting elements at specific area

New Here ,
Nov 26, 2023 Nov 26, 2023

Copy link to clipboard

Copied

Hello guys,

 

is there a simple way how to select all the elements at specific area? Lets say, I need to select everything in rectangle 0,0 to 200,200? Only option I have got so far is to make a rectangle and go through all the objects and select all that intersects. This works, but I need to perform this several times in different areas and I have a lot of objects on the artboard, which make it pretty slow approach? Moreover, is there any way how to select guidelines as well? Previously mentioned approach doesnt work.

 

thanks for any answer

TOPICS
Scripting

Views

310

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Nov 26, 2023 Nov 26, 2023

Copy link to clipboard

Copied

How about a flow that creates a temporary artboard in the specified region and selectObjectsOnActiveArtboard to select the contents?

 

/**
  * @￰file select page items in the specified bounds using selectObjectsOnActiveArtboard
  * @￰version 1.0.0
  * @￰author sttk3.com
*/

(function() {
  selectRegion(app.documents[0], [0, 0, 200, -200]) ;
})() ;

/**
  * select page items in the specified bounds
  * @￰param {Document} doc target document
  * @￰param {[number, number, number, number]} bounds left, top, right, bottom
  * @￰returns {Array<PageItem>} new selection
*/
function selectRegion(doc, bounds) {
  var res = [] ;
  var tempArtboard ;
  try {
    tempArtboard = doc.artboards.add(bounds) ;
    doc.selectObjectsOnActiveArtboard() ;
    res = doc.selection ;
  } finally {
    if(tempArtboard) {tempArtboard.remove() ;}
  }
  return res ;
}

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 27, 2023 Nov 27, 2023

Copy link to clipboard

Copied

Pretty smart.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 03, 2023 Dec 03, 2023

Copy link to clipboard

Copied

Nice!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 22, 2023 Dec 22, 2023

Copy link to clipboard

Copied

LATEST

Thanks guys, this works beautifully!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines