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!
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
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.
Copy link to clipboard
Copied
let's see your layers panel, are the numbered text items in their own layer?
Copy link to clipboard
Copied
Yup! It's Recent Completions Comps, each number is on its own Text Path.
Copy link to clipboard
Copied
great, can you expand that layer please?
Copy link to clipboard
Copied
The circle backgroud and outline is an appearance/graphic style.
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
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.
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.
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
Copy link to clipboard
Copied
awesome!!
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;
}
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'];
Copy link to clipboard
Copied
that's correct, but you would have two sets that start with one using my script.
Copy link to clipboard
Copied
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!