Copy link to clipboard
Copied
Hello,
Do you have script for renaming artboard?
1. Rename artboard for Front side and Back side:
Artboard 1: Front
Artboard 2: Back
and placed it to the TOP LEFT
2. This is only 6 artboard for example, do you have shortcut for this?
I'm doing this by renaming artboard 1 by 1
then typing it in artboard 1 by 1.
S1F = Sheet 1 Front
S1B = Sheet 1 Back
thank you
1 Correct answer
Hi,
The error that you getting S is undefined because S should be used inside the quotes "" like "S"
And for you latest requirement please try following snippet
function main() {
var doc = app.activeDocument;
artBoards = doc.artboards;
var count = 1;
for (var i = 1; i <= artBoards.length; i++) {
var a = artBoards[i - 1];
if (i % 2 == 0) { // even number
a.name = "S" + (count) + "B";
count++;
}
else { // odd number
a.name = "S" + (count) + "F";
}
// Adding textframes
...
Explore related tutorials & articles
Copy link to clipboard
Copied
Hi, for your first part try following snippet
function main() {
var doc = app.activeDocument;
doc.artboards[0].name = "FRONT";
doc.artboards[1].name = "BACK";
}
main();
For your second part, try this one
function main() {
var doc = app.activeDocument;
artBoards = doc.artboards;
var count = 1;
for (var i = 1; i <= artBoards.length; i++) {
var a = artBoards[i - 1];
a.name = "S" + (count) + "F";
if (i % 2 == 0)
count++;
}
}
main();
I would suggest to make a generalized version of the script to rename the artboards that will run for your workflow. For this you may need to think over the workflow of your work. But above version script will work for teh question of have asked.
Let us know if this help you.
Copy link to clipboard
Copied
Thanks for your help,
You can disregard the first part.
for the second part:
Can you make the 'odd number' of artboard (1,3,5,7,9 ~)
Artobard1: S1F
Artobard3: S2F
Artobard5: S3F
and 'even number' of artboard (2,4,6,8,10 ~)
Artobard2: S1B
Artobard4: S2B
Artobard6: S3B
Thank you
Copy link to clipboard
Copied
Hi,
The error that you getting S is undefined because S should be used inside the quotes "" like "S"
And for you latest requirement please try following snippet
function main() {
var doc = app.activeDocument;
artBoards = doc.artboards;
var count = 1;
for (var i = 1; i <= artBoards.length; i++) {
var a = artBoards[i - 1];
if (i % 2 == 0) { // even number
a.name = "S" + (count) + "B";
count++;
}
else { // odd number
a.name = "S" + (count) + "F";
}
// Adding textframes
artBoards.setActiveArtboardIndex(i - 1);
var _textFrame = doc.textFrames.add();
_textFrame.contents = a.name;
_textFrame.top = a.artboardRect[1] - 10;
_textFrame.left = a.artboardRect[0] + 10;
}
}
main();
Let us know if it resolves your problem.
EDIT : Edit script to incorporate to show textframes for printing purpose with name of the artboard.
Copy link to clipboard
Copied
wow! Thank you, that works great.
but one last thing.
can you add the artboard name in the artboard itself like a small label? I need this for printing
please see attached
Copy link to clipboard
Copied
Hi,
I have updated the script with changes to have artboard names over the artboard for printing purpose above. You can use updated version of the script.
Let us know if it works for you.
Copy link to clipboard
Copied
its PERFECT!
thank you very much !!!
I have so many idea but I don't know how to code and if it's possible.
but this script will simplify my work (a bit hehe)
THANK YOU
Copy link to clipboard
Copied
You're welcome 🙂 .
Glad it is helpful for you.
Copy link to clipboard
Copied
Hello,
can I ask another favor?
can you make the label in another layer and locked?
thanks for your help..
Copy link to clipboard
Copied
« Give a man a fish and he will be full. Teach him how to fish and he will never go hungry again. »
attributed to Confucius
Try to learn the basics.
create a new layer
var doc = app.activeDocument;
var lay = doc.layers.add();
This layer is now the active layer.
add your text frame, create contents and lock the item
var tf = lay.textFrames.add();
tf.contents = "new contents";
tf.locked = true;
Try combining these lines of code with the script written by @Charu Rajput and ask later if you need further assistance.
Have fun
😉

