Jun 19, 2009

Fixing Sequential Numbers

[edit: 2018-10-03]
a script for Adobe Illustrator CSx-CCx

For the selected text objects, this script changes each content so that they become a sequential numerical values at even intervals from the backmost value to the foremost value.

For the number of decimal places and the number of zero-filled digits, the largest one of the foremost value and the backmost value is adopted.
(Fractions are rounded off as necessary.)

ex. (the left end is the backmost and the right end is the foremost)
  • 1 1 1 1 5     -> 1 2 3 4 5
  • 1.0 x x x 5   -> 1.0  2.0  3.0  4.0  5.0
  • 1 1 1 1 5.00  -> 1.00  2.00  3.00  4.00  5.00
  • 1.0 1 1 1 6   -> 1.0  2.3  3.5  4.8  6.0
  • 1 1 1 1 6     -> 1 2 4 5 6
  • 01 1 1 1 5    -> 01 02 03 04 05
  • 00 1 1 1 1 10 -> 00 02 04 06 08 10
 download:
 http://shspage.com/aijs/b_aics_script_fixing_sequential_numbers_20181003.zip

7 comments:

  1. would love to use this - but copying your steps above gives me the error 'typeError: cannot read property '0' from undefined'

    Additionally - I'd like to have a sequence from 0001 to 0025. Any thoughts?

    ReplyDelete
  2. Please make sure to select whole text objects before run the script. If you got the error even if you did so, please let me know the version of AI you use, and the numbers you selected. If you use CS4, it may need to modify "activeDocument" to "app.activeDocument".

    I'll write a script that make a 0001-0025 sequence after this problem is fixed.

    ReplyDelete
  3. Hi Hiroyuki!

    Using CS4 so I updated to reflect app.activeDocument but it now gives another error: Type Error: Cannot read property "selection" from undefined.

    I did a simple test of four digits - 0 is the first and 3 is the last.

    ideally it'd most be used for counting in 10s, or 20s etc.

    so like 0, 10, 20, 30, 40
    and 0, 20, 40, 60, 80, 100

    but with zero leaders like:
    000, 020, 030, 040, 060

    not sure if that would work but it'd be great!

    ReplyDelete
  4. Hi jayse,
    I don't have CS4, so I can't test the script with it. But I found a expression "app.activeDocument.selection" in a sample code in AI CS4 JavaScript reference PDF.
    So the error message you encountered is mysterious...

    Anyway, I wrote a script that supports zero leaders. Here is a url for download. I hope it works.

    http://park12.wakwak.com/~shp/cgi-bin/dl.cgi/b_aics_script_fixing_sequential_numbers.zip

    ReplyDelete
  5. Hiroyuki you did it! Works perfectly~! I'm just getting into scripting for AI so this helps a ton to see what you did and how you coded it. Thanks a mega-ton!

    ReplyDelete
  6. The script in my above message has moved to the following address.
    http://shspage.com/aijs/b_aics_script_fixing_sequential_numbers.zip

    ReplyDelete
  7. The latest version is here: http://shspage.com/aijs/b_aics_script_fixing_sequential_numbers_20181003.zip
    as written in above article updated today.

    ReplyDelete

Note: Only a member of this blog may post a comment.