: Script to nudge by 1/10 in Illustrator I wrote a script to nudge by 1/10 in Illustrator (like in InDesign). It works, but only for the whole object, even if I only select some anchors. Is
I wrote a script to nudge by 1/10 in Illustrator (like in InDesign). It works, but only for the whole object, even if I only select some anchors. Is there a way for it to work as well when only anchors (or paths) are selected?
Here is the script:
var myDis = app.preferences.getRealPreference ('cursorKeyLength');
var myDis = myDis/10
var myDoc = app.activeDocument;
var mySel = myDoc.selection;
for ( var i = 0; i < mySel.length; i++ ) {
mySel[i].top = mySel[i].top-myDis; // so it moves by 1/10 of the cursorKeyLength to the top
}
Thanks!
More posts by @Alves566
2 Comments
Sorted by latest first Latest Oldest Best
I don't understand why you need a script for this.....
Set the Keyboard Increment in the preferences to 5:
Tap any arrow key - ←, →, ↑, ↓ ... the nudge is 5
Hold the Command/Ctrl key down and tap any arrow key - ←, →, ↑, ↓ ... the nudge is 0.5 (1/10 the increment setting) (this only works in InDesign, Illustrator won't recognize this)
Hold the Shift key down and tap any arrow key - ←, →, ↑, ↓ ... the nudge is 50 (10x the increment setting)
This works with any selection be it merely anchor points or whole objects.
You can get a 1/10 nudge of any value just by using modifier keys in InDesign. If using an action, the modifiers are recorded. If using Illustrator I just set my nudge to a very small amount, then use Shift when I need it larger.
But then, perhaps I just don't understand why you feel a script is necessary.
Here's what I came with, wich will move selected anchors to the left by 1/10 of the Keyboard Increment saved in the Preferences:
var myLength = app.preferences.getRealPreference('cursorKeyLength') / 10,
mySelection = app.activeDocument.selection,
myDistance = [0 - myLength, 0]; // move selected anchors to the left
for (var i = 0; i < mySelection.length; i++) {
// for anchors
if (mySelection[i].typename === 'PathItem') {
var p = mySelection[i].pathPoints;
for (j = 0; j < p.length; j++) {
if (p[j].selected === PathPointSelection.ANCHORPOINT) {
with(p[j]) {
anchor = [anchor[0] + myDistance[0], anchor[1] + myDistance[1]];
leftDirection = [leftDirection[0] + myDistance[0], leftDirection[1] + myDistance[1]];
rightDirection = [rightDirection[0] + myDistance[0], rightDirection[1] + myDistance[1]];
}
}
}
}
// for anything else
else {
with(mySelection[i]) {
position = [position[0] + myDistance[0], position[1] + myDistance[1]];
}
}
}
To move the anchors in another direction, change variable myDistance:
var myDistance = [0 - myLength, 0]; // leftward
var myDistance = [0 + myLength, 0]; // rightward
var myDistance = [0, 0 + myLength]; // upward
var myDistance = [0, 0 - myLength]; // downward
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.