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

Artboard name

Explorer ,
Jul 08, 2020 Jul 08, 2020

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

elinochinjr_1-1594270650832.pngexpand image

 

 

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

 

elinochinjr_2-1594270671285.pngexpand image

 

thank you

 

TOPICS
Scripting , Tools
1.1K
Translate
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 1 Correct answer

Community Expert , Jul 08, 2020 Jul 08, 2020

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
...
Translate
Adobe
Community Expert ,
Jul 08, 2020 Jul 08, 2020

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.

 

Best regards
Translate
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 ,
Jul 08, 2020 Jul 08, 2020

Thanks for your help,

 

You can disregard the first part. 

for the second part:

elinochinjr_2-1594275347754.pngexpand image

 

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

Translate
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 ,
Jul 08, 2020 Jul 08, 2020

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.

Best regards
Translate
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 ,
Jul 09, 2020 Jul 09, 2020

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

elinochinjr_0-1594278195948.pngexpand image

 

Translate
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 ,
Jul 09, 2020 Jul 09, 2020

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.

Best regards
Translate
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 ,
Jul 09, 2020 Jul 09, 2020

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

Translate
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 ,
Jul 09, 2020 Jul 09, 2020

You're welcome 🙂 .

Glad it is helpful for you.

Best regards
Translate
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 ,
Jul 09, 2020 Jul 09, 2020

Hello,

 

can I ask another favor?

can you make the label in another layer and locked?

elinochinjr_0-1594347109161.pngexpand image

 

thanks for your help..

Translate
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 ,
Jul 09, 2020 Jul 09, 2020
LATEST

« 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

😉

Translate
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