Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Deselect objects script

New Here ,
Nov 08, 2012 Nov 08, 2012

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?

TOPICS
Scripting
4.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Nov 08, 2012 Nov 08, 2012

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,

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 08, 2012 Nov 08, 2012

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?)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2012 Nov 08, 2012

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2012 Nov 08, 2012

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?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 09, 2012 Nov 09, 2012

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 09, 2012 Nov 09, 2012

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Nov 09, 2012 Nov 09, 2012

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 09, 2012 Nov 09, 2012

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).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 11, 2012 Nov 11, 2012

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")

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 11, 2012 Nov 11, 2012

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.

tickMarks.PNG

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 11, 2012 Nov 11, 2012

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 11, 2012 Nov 11, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 11, 2012 Nov 11, 2012

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.


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 16, 2012 Nov 16, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 16, 2012 Nov 16, 2012
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 11, 2012 Nov 11, 2012

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

graphTickMarks.PNG

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines