Copy link to clipboard
Copied
Hello
Is there any way to script the deselection of for example 9 out of 10 selected lines, sorted from left to right?
So if I have 100 lines selected, the result will be only 10 selected lines evenly spread out.
I'm using CS 5.5.
Anyone?
Copy link to clipboard
Copied
first, sort your paths based on their x position (currently they're sorted by their stacking order). Next, loop and set every 10th path's selected property to false,
Copy link to clipboard
Copied
Thanks for your interesting answer. As I know nothing about scripting: Is there any way to sort and loop manually? (and then using an action?)
Copy link to clipboard
Copied
oh, ok, no manually you can't loop, then what else do you need to do with the 10 selected lines, or with the 90 other deselected lines?
Copy link to clipboard
Copied
Are the lines in text frames or text areas?
and I repeat:
CarlosCanto wrote:
… what else do you need to do with the 10 selected lines, or with the 90 other deselected lines?
Copy link to clipboard
Copied
Thanks for your answers
1. The lines are the tick marks in a graph's category axis.
2. The 10 selected lines is what I want to remain. So if I get them selected, I'll probably lock them, and then select the remaining 90 lines and delete them.
How do I progress in order to make a script?
Copy link to clipboard
Copied
How do I progress in order to make a script?
if you know nothing about scripting or programming, you can start by reading the Guides supplied with Illustrator, however, they won't teach you the language itself (it assumes you're familiar with programing already), it merely shows you how to apply the scripting language to the illustrator object model. To learn the language itself you have to get a book or two, or the web...and this forum has a ton of complete scripts about pretty much everything scriptable in illustrator.
while you learn, we'll get the script done for you, right after the following...
...this question is related to your other post, before we continue, you realize you need to break your "live" chart, right? otherwise if you want to keep it as a chart, you won't be able to delete your 90 paths.
Copy link to clipboard
Copied
My guess is that it is related to the graph issue… Yes script can do this but as I pointed out in the other post script can only do so after breaking the graph data apart…
People here can and will help where they can just be clear about what you require and why… Are you bothered if a graph looses its ability to be modified in AI?
Copy link to clipboard
Copied
Thanks for your input
It's no problem that the script "breaks" the graph as the script can be applied at the end after all the formating has been done (it's for print).
Copy link to clipboard
Copied
It's difficult to "break" graph with script, because you get grouped grouped grouped items.
IMHO the problem will be to select the tick marks with script.
To deselect or remove 9 of 10 (or of 100) lines you can give this script a chance:
#target Illustrator
// Remove9of10.jsx
// graph must be breaked;
// only if category axis is the x-axis;
// all selected tick marks must be ungrouped;
//the first tick mark (on position 0 in graph) is also deselected/removed
//by pixxxelschubser
var myDoc = app.activeDocument;
var Sel = myDoc.selection;
var SelLen = Sel.length;
var p1 = Sel[0].position[0];
var p2 = Sel[SelLen-1].position[0];
if (p1 != p2) {
if (p1 < p2) {
for ( i = SelLen-1; i >= 0; i--) {
if (i/10 != Math.round (i/10) || i/10 == 0) {
Sel.selected = false; //to remove, change this line with next line
//Sel.remove();
redraw();
}
}
} else {
for ( i = 0; i <= SelLen-1; i++) {
if (i/10 != Math.round (i/10) || i/10 == 0) {
var j= SelLen-1 - i;
Sel
.selected = false; //to remove, change this line with next line //Sel
.remove(); redraw();
}
}
}
} else {
alert("only for x-axis")
}
Copy link to clipboard
Copied
hi pixxxel, I don't think there's a way to "break" the graph via scripting, I didn't see how in the guide, that part would have to be done by hand....wait, I wonder if one could use "sendkeys" to ungroup, or I heard one has access to menu commands in CS6...nah, too much trouble to use sendkeys and using menu commands would limit the script to CS6 only.
once the graph is ungrouped, you're right about getting to the tick marks since they're buried within a bunch of groups, that might be tricky.
and, your script works fine with nicely arranged lines, but I tried with real graph data, and the Data Points lines get mixed up nicely with the tick marks visually but they placed at the bottom of the stacking order, and that's messing up the order of the lines.
Copy link to clipboard
Copied
Yes, I agree completely with you.
That was exactly, what I would like saying before.
(Or: That was exactly what I want to say before.) ???
Do you know, what I mean?
Copy link to clipboard
Copied
That was exactly what I would like saying before - No (I would like, refers to the future)
That was exactly what I want to say before - almost (I want to, refers to the present)
That was exactly what I wanted to say before - better
phew!! that was hard, grammar proved to be more difficult than programming!! hahaha
Copy link to clipboard
Copied
Thanks for the great tuition.
CarlosCanto wrote:
… phew!! that was hard, grammar proved to be more difficult than programming!! hahaha
Now you know how I feel. I learned „my English“ 25 years ago and since then no longer needed.
Scripting is indeed easier.
Copy link to clipboard
Copied
Great work! Thanks a lot!
Is there any way to manually input via e.g. a dialog the ratio that is removed/selected?
(Sorry for my late reply, I've been out of country)
Have a nice day
Magnus
Copy link to clipboard
Copied
That would be the easiest option:
#target Illustrator
// Remove9of10.jsx
// graph must be breaked;
// only if category axis is the x-axis;
// all selected tick marks must be ungrouped;
// http://forums.adobe.com/thread/1095789?tstart=0
// the first tick mark (normaly on position 0 in graph) is also deselected/removed
// by pixxxelschubser
var myDoc = app.activeDocument;
var Sel = myDoc.selection;
var SelLen = Sel.length;
var p1 = Sel[0].position[0];
var p2 = Sel[SelLen-1].position[0];
var x = 10;
x = prompt ("Receive each xth line", x);
if (p1 != p2) {
if (p1 < p2) {
for ( i = SelLen-1; i >= 0; i--) {
if (i/x != Math.round (i/x) || i/x == 0) {
Sel.selected = false; //to remove, change this line with next line
//Sel.remove();
redraw();
}
}
} else {
for ( i = 0; i <= SelLen-1; i++) {
if (i/x != Math.round (i/x) || i/x == 0) {
var j= SelLen-1 - i;
Sel
.selected = false; //to remove, change this line with next line //Sel
.remove(); redraw();
}
}
}
} else {
alert("only for x-axis")
}
Have fun
Copy link to clipboard
Copied
Maggern, what about a different approach? what if you leave the tick marks off completely and draw them by hand (or perhaps by script) separately?
I drew two lines and used a blend between them in no time
Find more inspiration, events, and resources on the new Adobe Community
Explore Now