"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;
}
"zoom to selected"
Started by
jmk
, Mar 01 2007 06:11 PM
2 replies to this topic
#1
Posted 01 March 2007 - 06:11 PM
#2
Posted 02 March 2007 - 01:20 AM
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...
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...
#3
Posted 24 March 2007 - 01:00 AM
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 "Access 2013 Essential Training"
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users


Sign In
Create Account
United States
Back to top
Sweden









