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

Auto numbering

Explorer ,
Sep 19, 2022 Sep 19, 2022

Copy link to clipboard

Copied

Hello everyone,
Here is my problem:
I have to name a lot of objects in my illus. plan in order to count them but I lost a lot of time by renaming each of them.

Paul25625680kp5n_0-1663576914908.png

I would like to know if it's possible to auto number a text box in order to have somthing like this when I'm duplicating the circle n°1.

Paul25625680kp5n_1-1663576962021.png

 

Thank you,
PM

 

Thank you

 

 

TOPICS
Scripting , Tools

Views

1.2K

Translate

Translate

Report

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

correct answers 2 Correct answers

Community Expert , Sep 20, 2022 Sep 20, 2022

No worries. Here's a script that does that:

/**
 * Increments the contents of first
 * selected text frame and sets contents
 * of subsequent selected text frames
 * according to counter.
 */
(function () {

    var doc = app.activeDocument,
        items = app.selection;

    for (var i = items.length - 1, n; i >= 0; i--) {
        if (items[i].constructor.name == 'TextFrame') {
            if (n == undefined)
                n = Number(items[i].contents);
            items[i].contents = ++n;
 
...

Votes

Translate

Translate
Community Expert , Sep 20, 2022 Sep 20, 2022

Yep have a try with this one:

/**
 * Increments the contents of first
 * selected text frame and sets contents
 * of subsequent selected text frames
 * according to counter.
 */
(function () {

    // prefix of each number
    var prefix = "CH. ";

    // the length of number
    var len = 3;

    var doc = app.activeDocument,
        items = app.selection;

    for (var i = items.length - 1, n; i >= 0; i--) {
        if (items[i].constructor.name == 'TextFrame') {
            if (n == undefined
...

Votes

Translate

Translate
Adobe
Community Expert ,
Sep 19, 2022 Sep 19, 2022

Copy link to clipboard

Copied

Similar requests have already been there in this forum. Some of them are pretty promising.

 

One approach that I'd recommend is a script called "NumeratesPoints", provided by Sergey Osokin. Its main advantage is that it allows you to control the order of the numeration based on the order of anchor points on a path.

 

For example, you can draw ten circles, (preferably) create a new layer, take the Pen tool, draw a path with anchor points exactly placed on the centre of the circles (or elsewhere). Then, while this path is selected, run the "NumeratesPoints" script, choose the appropriate settings in the script dialog and finally delete the path and the marker points if you don't need them.

 

See here: NumeratesPoints

 

Votes

Translate

Translate

Report

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
Explorer ,
Sep 19, 2022 Sep 19, 2022

Copy link to clipboard

Copied

Thank you Kurt for your response, unfortunately this is not what I expected..

I just want that the box I duplicate change automatically the number of the text box.
Exemple: I have written "1" in my text box -> I duplicate the textbox -> I now have "2" written in my new text box.

Thank you again

Votes

Translate

Translate

Report

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 ,
Sep 19, 2022 Sep 19, 2022

Copy link to clipboard

Copied

This might be possible using either scripting in Illustrator (so a .js) or using a third party app such as Alfred. The approach would be to use a hotkey to activate the script. The script would take the contents of the clipboard, see it as a numerical value, then iterate the value, replace the contents of the clipboard, then paste it back onto the board. I have not done this kind of thing myself, just saying that if I had this kind of workflow issue then this is how I would approach it.

Votes

Translate

Translate

Report

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 ,
Sep 19, 2022 Sep 19, 2022

Copy link to clipboard

Copied

can you share a sample file? or at least show your layer structure?

Votes

Translate

Translate

Report

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
Guide ,
Sep 19, 2022 Sep 19, 2022

Copy link to clipboard

Copied

It depends on your workflow. Scripts are not dynamic. A script cannot change the contents at the moment you duplicate a text frame manually. I see two options.

 

First, the script incrementally adds 1 to the contents of selected text frames, the script being run immediately after doing the duplicating manually.

 

Second, the script duplicates a selected text frame, once or a specified number of times, adding 1 to the contents each time. You either position the duplicates manually or through the script (e.g. at the tail of the preceding text frame).

Votes

Translate

Translate

Report

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 ,
Sep 19, 2022 Sep 19, 2022

Copy link to clipboard

Copied

Hi @polotrobo, as others have said, the scripting API doesn't give access to duplicate page item event so it can't be automatic unless you create a plug-in, which is much more involved.

 

However, my solution to this type of problem is to

(a) put all the numbering markers on a layer of their own, eg mine is called "numbering",

(b) duplicate them in order, starting at 1

(c) run this script:

 

/**
 * Sets the contents of first text frame
 * of every group item on specified layer
 * to the value of a counter.
 */
(function () {

    var doc = app.activeDocument,
        numberingLayer = doc.layers.getByName('numbering'),
        items = numberingLayer.groupItems;

    for (var i = items.length - 1, n = 1; i >= 0; i--, n++)
        items[i].textFrames[0].contents = n;

})();

 

(d) to adjust the order afterwards, just move the markers up or down in the layer panel and run the script again.

That's how I would do it.

- Mark

Make the default markerMake the default marker

Duplicate the markers *in order*Duplicate the markers *in order*

After running scriptAfter running script

 

Votes

Translate

Translate

Report

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
Explorer ,
Sep 20, 2022 Sep 20, 2022

Copy link to clipboard

Copied

Hi @m1b your script is almost perfect !

1: Your script has to run with a group of text and ellipse, I would like to run it just with the text.

2: I would like to run the script from the active number of my textbox, exemple: I want to start the script from the number 312 in order to have the next numbers, 313, 314 etc..

Thank you all for your help I've learnt a lot from your tips!

Votes

Translate

Translate

Report

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 ,
Sep 20, 2022 Sep 20, 2022

Copy link to clipboard

Copied

No worries. Here's a script that does that:

/**
 * Increments the contents of first
 * selected text frame and sets contents
 * of subsequent selected text frames
 * according to counter.
 */
(function () {

    var doc = app.activeDocument,
        items = app.selection;

    for (var i = items.length - 1, n; i >= 0; i--) {
        if (items[i].constructor.name == 'TextFrame') {
            if (n == undefined)
                n = Number(items[i].contents);
            items[i].contents = ++n;
        }
    }

})();

Votes

Translate

Translate

Report

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
Explorer ,
Sep 20, 2022 Sep 20, 2022

Copy link to clipboard

Copied

You're amazing @m1b thank you so much !!

Votes

Translate

Translate

Report

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
Explorer ,
Sep 20, 2022 Sep 20, 2022

Copy link to clipboard

Copied

Just a last thing, in the script you gave me I would like to add a static text in order to have "CH. 001"
when my text is "1".
Exemple if I duplicate a lot of "1" I will have "CH. 001", "CH. 002", "CH. 003", "CH. 004".

 

It would be so perfect if you could solve my problem !!

Thank you again

Votes

Translate

Translate

Report

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 ,
Sep 20, 2022 Sep 20, 2022

Copy link to clipboard

Copied

Yep have a try with this one:

/**
 * Increments the contents of first
 * selected text frame and sets contents
 * of subsequent selected text frames
 * according to counter.
 */
(function () {

    // prefix of each number
    var prefix = "CH. ";

    // the length of number
    var len = 3;

    var doc = app.activeDocument,
        items = app.selection;

    for (var i = items.length - 1, n; i >= 0; i--) {
        if (items[i].constructor.name == 'TextFrame') {
            if (n == undefined)
                n = Number(items[i].contents.replace(/\D/g,''));
            items[i].contents = prefix + ('000' + (++n)).slice(-len);
        }
    }

})();

Votes

Translate

Translate

Report

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
LEGEND ,
Sep 20, 2022 Sep 20, 2022

Copy link to clipboard

Copied

@m1b has provided an awesome solution!

Have you considered using Illustrator "Appearances" and "Graphic Styles" to automate the circles around each text frame? This would eliminate the need for groups and static ellipse objects.

rcraighead_0-1663704962902.png

 

Votes

Translate

Translate

Report

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 ,
Sep 20, 2022 Sep 20, 2022

Copy link to clipboard

Copied

Nice!

Votes

Translate

Translate

Report

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
Explorer ,
Sep 22, 2022 Sep 22, 2022

Copy link to clipboard

Copied

Hi mark,

Thank you again for the script, I used it a lot but I would like to run a similar script for other thing, here is my problem:

polotrobo_1-1663854262343.png

I now need to count some groups in a specific layer. I would like to run a script which search in the layer called "VEI" to find all the groups with "PEH" et "PEV" included in order to count them by adding numbers.

polotrobo_2-1663854355242.png

Thank you again
Paul

Votes

Translate

Translate

Report

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
Explorer ,
Sep 22, 2022 Sep 22, 2022

Copy link to clipboard

Copied

LATEST

@m1b 

Votes

Translate

Translate

Report

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
Explorer ,
Sep 21, 2022 Sep 21, 2022

Copy link to clipboard

Copied

@m1b Amazing ! That's all I needed thank you so much

Votes

Translate

Translate

Report

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