Copy link to clipboard
Copied
Hello,
Is there a simple solution via a JavaScript that would allow me to (once I have selected a point) automatically select all of the points that land on that same
Y-Axis?
Possibly even adding points to paths on that same Y-Axis (like in the case of the S in the attached image)?
I am hoping to copy them, move them by .125 below and convert them to rectangles.
I am able to do all of this with an action but the first step.
Any help would be great thank you!
1 Correct answer
So you want something like this ?
...#target illustrator
function test(){
var doc = app.activeDocument;
var selectedItem = doc.selection[0];
var selectedPoints = selectedItem.selectedPathPoints;
var selectedPoint;
var tolerance = 2;
for(var i = 0; i < selectedPoints.length; i++){
if(selectedPoints.selected == PathPointSelection.ANCHORPOINT){
selectedPoint = selectedPoints;
}
};
var sampleY = selectedPoint.anchor[1];
selectedPoint.selected
Explore related tutorials & articles
Copy link to clipboard
Copied
Yea you can try this!
Change the tolerance to include more points along a wider buffer area.
#target illustrator
function test(){
var doc = app.activeDocument;
var selectedItem = doc.selection[0];
var selectedPoints = selectedItem.selectedPathPoints;
var selectedPoint;
var tolerance = 2;
for(var i = 0; i < selectedPoints.length; i++){
if(selectedPoints.selected == PathPointSelection.ANCHORPOINT){
selectedPoint = selectedPoints;
}
};
var thisPath, thisPathPoint;
for(var i = 0; i < doc.pathItems.length; i++){
thisPath = doc.pathItems;
for(var j = 0; j < thisPath.pathPoints.length; j++){
thisPathPoint = thisPath.pathPoints
; if(
(thisPathPoint.anchor[1] - tolerance <= selectedPoint.anchor[1] && thisPathPoint.anchor[1] + tolerance >= selectedPoint.anchor[1])
){
thisPathPoint.selected = PathPointSelection.ANCHORPOINT;
}
};
};
};
test();
Copy link to clipboard
Copied
This is great! Thank you!
Copy link to clipboard
Copied
It's exactly what I asked for but Illustrator did not function the way I was expecting. So it looks like I'm going to have to tackle this a bit differently.
Copy link to clipboard
Copied
Oh no! So what was it doing?
Copy link to clipboard
Copied
The Script is doing nothing wrong I'm just ending up with extra line segments. It's almost like I need it to select all of the points -except- the ones on the Y-axis so I can delete them away.
and end up with this.
Copy link to clipboard
Copied
So you want something like this ?
#target illustrator
function test(){
var doc = app.activeDocument;
var selectedItem = doc.selection[0];
var selectedPoints = selectedItem.selectedPathPoints;
var selectedPoint;
var tolerance = 2;
for(var i = 0; i < selectedPoints.length; i++){
if(selectedPoints.selected == PathPointSelection.ANCHORPOINT){
selectedPoint = selectedPoints;
}
};
var sampleY = selectedPoint.anchor[1];
selectedPoint.selected = PathPointSelection.NOSELECTION;
var thisPath, thisPathPoint;
for(var i = 0; i < doc.pathItems.length; i++){
thisPath = doc.pathItems;
for(var j = 0; j < thisPath.pathPoints.length; j++){
thisPathPoint = thisPath.pathPoints
; if(
!(thisPathPoint.anchor[1] - tolerance <= sampleY && thisPathPoint.anchor[1] + tolerance >= sampleY)
){
thisPathPoint.selected = PathPointSelection.ANCHORPOINT;
}
};
};
};
test();
Copy link to clipboard
Copied
Your script is useful
Thanks for dedication
Copy link to clipboard
Copied
I want to divide the text quickly by the space character.
Friend, can you write this for me?
Copy link to clipboard
Copied
Sorry, the work entailed for accomplishing your task is more involved than some of the simpler snippets and unfortunately I'm quite booked up at the moment with some clients. Perhaps another contributor can help you out, and maybe I may get some chance to take a break and analyze your problem further - but this time may be some weeks in duration.
However, I can set you on the path to the simplest way this could be done. You will need to use one of the scripts found on this forum which can apply a character style via regular expression, because you will need to find each of your spaces and style them differently, such as with a different character color.
The trick to avoid work is, to use the Flatten Transparency command to accomplish your task! When you have an area text and use Flatten Transparency, but without "Convert text to outlines" checked, it will make each line in your area text into point text and it would also create breaks in the point text where the spaces used to be - provided you have indeed colored each whitespace character with a color different from the normal character color.
Copy link to clipboard
Copied
Silly-V,
Sorry to ask but is there a way to automatically select an Anchor Point? It will always be the Lowest point (and because there will be multiple on that Y-axis I choose the Left most point.
If not or it would add substantially more scripting I completely understand and with work with what you have already given me
Thank you again for the assist!

