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
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 ;
}
Copy link to clipboard
Copied
Pretty smart.
Copy link to clipboard
Copied
Nice!
Copy link to clipboard
Copied
Thanks guys, this works beautifully!