Jump to content

 
Photo

"zoom to selected"

- - - - -

  • Please log in to reply
2 replies to this topic

#1
jmk

jmk

    Newbie

  • Validated Member
  • Pip
  • 3 posts
  • United States

"Zoom to selected": if this has been discussed before and you all have illustrator scripts for it already, please ignore. If not, I'll see if I can paste mine here. I use the tool all the time in GIS, especially to double-check what I will be editing. I was surprised I couldn't readily find one for illy. I intended to record an action around the script, so that I could use a shortcut key, but I had some trouble having my actions persist through sessions, so now I usually run the script from the File menu. Aside: how do you keyboard up to the menus? I'm used to Alt, then F, etc. for the accelerator keys, but in illy Alt doesn't seem to do that. I mapped to "ctrl q" in Arc; it looks like ESRI has made a shortcut of "ctrl shift =" in 9.2, so maybe I'll map it to that in Illy.

zoomTo();

function zoomTo()
{
selectedItems = selection;
foo = selectedItems.length
//alert(foo + " selected");

// check to make sure something is selected.
if ( selectedItems.length == 0) {
alert("Nothing is selected");
return;
}

//endIndex = selectedItems.length;

var myArray = new Array();

//if (app.documents.length > 0 ) {

selTop = selectedItems[0].top;
selLeft = selectedItems[0].left;
selHeight = selectedItems[0].height;
selWidth = selectedItems[0].width;

selBottom = selTop - selHeight;
selRight = selLeft + selWidth;
grpBottom = selBottom;
grpRight = selRight;

for (i = 0; i < selectedItems.length; i++) {
//alert(i + " selected: " + selectedItems.length );

selBottom = selectedItems[i].top - selectedItems[i].height;
selRight = selectedItems[i].left + selectedItems[i].width;

if (selectedItems[i].top > selTop) { selTop = selectedItems[i].top;}
if (selectedItems[i].left < selLeft) { selLeft = selectedItems[i].left;}
//if (selectedItems[i].height > selHeight) { selHeight = selectedItems[i].height;}
//if (selectedItems[i].width > selWidth) { selWidth = selectedItems[i].width;}

if (selBottom < grpBottom) { grpBottom = selBottom;}
if (selRight > grpRight) { grpRight = selRight;}

}

b0 = documents[0].views[0].bounds[0];
b1 = documents[0].views[0].bounds[1];
b2 = documents[0].views[0].bounds[2];
b3 = documents[0].views[0].bounds[3];
z = documents[0].views[0].zoom;

widView = b2-b0;

z2 = z*widView/selectedItems[0].width;
//myArray[0] = selLeft + (selWidth)/2;
//myArray[1] = selTop - (selHeight)/2;
myArray[0] = selLeft + (grpRight - selLeft)/2; //(selLeft + grpRight)/2;
myArray[1] = selTop - (selTop - grpBottom)/2; //(selTop + grpBottom)/2;

//alert (myArray[0] + " 0 myArray 1 " + myArray[1] + " z2: " + z2);

heiView = b1-b3;

selHeight = selTop - grpBottom;
selWidth = grpRight - selLeft;

if (selWidth/selHeight < widView/heiView) {
//alert (selWidth/selHeight + "<" + widView/heiView);
z2 = .9*z*heiView/selHeight;
}

if (selWidth/selHeight > widView/heiView) {
//alert (selWidth/selHeight + ">" + widView/heiView);
z2 = .9*z*widView/selWidth;
}

documents[0].views[0].zoom = z2;
documents[0].views[0].centerPoint = myArray;


}

#2
frax

frax

    Hall of Fame

  • Associate Admin
  • PipPipPipPipPipPipPip
  • 2,304 posts
  • Gender:Male
  • Location:Stockholm, Sweden
  • Interests:music, hiking, friends, nature, photography, traveling. and maps!
  • Sweden

looks interesting, I will look at that. Thanks for the tips on using actions to create shortcuts for scripts too, I didn't know one could do that.

Does any keyboard shortcuts work for you in Illy? If not, I think you are encountering something that can happen on a pirated install of Illy, which might not be your case, but maybe you should try reinstalling... ?

Alt-f gives me the file menu allright, in my Illy...
Hugo Ahlenius
Nordpil - custom maps and GIS
http://nordpil.com/
Twitter

#3
Adam Wilbert

Adam Wilbert

    Legendary Contributor

  • Validated Member
  • PipPipPipPipPip
  • 274 posts
  • Gender:Male
  • Location:Bellingham, WA, USA
  • United States

the keyboard shortcuts don't work when CapsLock is turned on. Maybe its as simple as that?

Adam Wilbert
CartoGaia.com & AdamWilbert.com
Lynda.com author of "Up and Running with ArcGIS"





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

-->