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

Script that auto-renumbers text?

Community Beginner ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

Hi there,

 

I have a vector map with about 30 numbers/points on it. I want to add a new point labeled #1, but would have to manually change every proceeding number by 1. I was wondering if there's a script that would auto-renumber this text for me? Would be amazing.

 

Thank you so much in advance!

 

MapPoints.png

TOPICS
Scripting , Third party plugins

Views

829

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 , Mar 26, 2021 Mar 26, 2021

alright, this script works by numbering all text frames in order, starting from number 1. The order will follow the stacking order in the layer panel, top most object is 1, next object below is 2, etc.

 

var idoc = app.activeDocument;
var workingLayer = idoc.layers['Recent Completions Comps'];

var numberedPoints = workingLayer.textFrames;

for (var a=0; a<numberedPoints.length; a++) {
    numberedPoints[a].contents = a+1;
}

 

let me know if that works for you

Votes

Translate

Translate
Community Expert , Mar 26, 2021 Mar 26, 2021

copy the script and paste into a plain text file. Save it as "anyName.jsx". Save it anywhere, to run the script, open your map, then go to File->Scripts->Other Scripts...then navigate to where you saved the script. done.

Votes

Translate

Translate
Adobe
Community Expert ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

let's see your layers panel, are the numbered text items in their own layer?

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 Beginner ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

Yup! It's Recent Completions Comps, each number is on its own Text Path.

Screen Shot 2021-03-26 at 2.56.57 PM.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 ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

great, can you expand that layer please?

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 Beginner ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

The circle backgroud and outline is an appearance/graphic style.

 

Screen Shot 2021-03-26 at 3.02.24 PM.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 ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

alright, this script works by numbering all text frames in order, starting from number 1. The order will follow the stacking order in the layer panel, top most object is 1, next object below is 2, etc.

 

var idoc = app.activeDocument;
var workingLayer = idoc.layers['Recent Completions Comps'];

var numberedPoints = workingLayer.textFrames;

for (var a=0; a<numberedPoints.length; a++) {
    numberedPoints[a].contents = a+1;
}

 

let me know if that works for you

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 Beginner ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

Thank you for sending, I'm sorry I'm trying to figure out how to get this to work and watching basic javascripting videos now.

 

I should have disclosed that I've never created a script before - just know how to download and file them in the right place, lol.

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 ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

copy the script and paste into a plain text file. Save it as "anyName.jsx". Save it anywhere, to run the script, open your map, then go to File->Scripts->Other Scripts...then navigate to where you saved the script. done.

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 Beginner ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

Okay that's definitely what I tried the first time, but I must have done something wrong. Tried it again and it WORKED omg THANK YOUUU

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 ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

awesome!!

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 ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

Here's a slight variation of Carlos' script that increments the current contents of the textframes:

var idoc = app.activeDocument;
var workingLayer = idoc.layers['Recent Completions Comps'];

var numberedPoints = workingLayer.textFrames;

for (var a=0; a<numberedPoints.length; a++) {
    numberedPoints[a].contents = parseInt(numberedPoints[a].contents)+1;
}

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 Beginner ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

Great thank you both of you! 

 

Separate question - say I have two different layers of two sets of numbers - lets call them Comps 1 and Comps 2...

 

would I just change the layer name in this line, when I want to renumber the specific layer I want and re-save the script?:

var workingLayer = idoc.layers['Recent Completions Comps'];

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 ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

that's correct, but you would have two sets that start with one using my 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
Community Beginner ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

LATEST

Okay, amazing y'all are so talented! It seems to work fine if I rename the layers the exact same thing. The top layer is the one that the script runs for.

 

Have a great weekend!

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