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

Automatically rename current artboard to something else.

Explorer ,
Apr 17, 2019 Apr 17, 2019

I don't know anything about scripting.  I wanted to know if it were possible to make a script that will rename the artboard that is currently selected to a different name.

For example.  I have a document that has 4 artboards on it.   All 4 of the artboards already have current names, (Proof, Artwork, etc.).  I need to add a new artboard to the existing document.  The new artboard has "Artboard 5" as the name.  I need to change that to "Job Jacket".  However, I need to do this for thousands of files, so I need a streamlined way to do it rather than clicking and typing through the artboards panel.

Other notes; some of the existing documents will have less existing artboards, and some will have more artboards.  This is why I ask if there is a way to only rename the currently selected artboard.

Is this possible?

TOPICS
Scripting
4.0K
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 , Apr 17, 2019 Apr 17, 2019

Try that

// set a new name eg "Job Jacket" for the active artboard in active document

var aDoc = app.activeDocument;

var abIdx = aDoc.artboards.getActiveArtboardIndex ();

aDoc.artboards[abIdx].name = "Job Jacket"; // set the new name here

Have fun

Translate
Adobe
Community Expert ,
Apr 17, 2019 Apr 17, 2019

Try that

// set a new name eg "Job Jacket" for the active artboard in active document

var aDoc = app.activeDocument;

var abIdx = aDoc.artboards.getActiveArtboardIndex ();

aDoc.artboards[abIdx].name = "Job Jacket"; // set the new name here

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
Community Expert ,
Apr 17, 2019 Apr 17, 2019

Adding to pixxxel schubsers great example: If a simple interactive method is required:

// https://forums.adobe.com/message/11034337#11034337

// set a new name eg "Job Jacket" for the active artboard in active document via prompt

var aDoc = app.activeDocument; 

var abIdx = aDoc.artboards.getActiveArtboardIndex (); 

var abName = prompt("Rename Active Artboard" + "\n" + "Enter a new name:", "Job Jacket");

aDoc.artboards[abIdx].name = abName;

prompt2.png

Prepression: Downloading and Installing Adobe Scripts

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 ,
Apr 18, 2019 Apr 18, 2019

Stephen_A_Marsh  wrote

Adding to https://forums.adobe.com/people/pixxxel+schubser great example: If a simple interactive method is required:

// https://forums.adobe.com/message/11034337#11034337 // set a new name eg "Job Jacket" for the active artboard in active document via prompt var aDoc = app.activeDocument;   var abIdx = aDoc.artboards.getActiveArtboardIndex ();   var abName = prompt("Rename Active Artboard" + "\n" + "Enter a new name:", "Job Jacket"); aDoc.artboards[abIdx].name = abName;

prompt2.png

Prepression: Downloading and Installing Adobe Scripts

This is really cool and might come in handy.  For this specific task, I wanted to make the process as quick as possible.  Thanks for the script though.  It might help someone else looking for something similar too!

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 ,
Apr 18, 2019 Apr 18, 2019

Thanks for the thanks! I guessed that it was probably overkill for your situation, however as I'm new to scripting and mostly hack away with Photoshop scripts it was a good exercise for me to reinforce these basic concepts. It was a simple enough and logical extension of the previous script so if it helps somebody else that is great!

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 ,
Apr 23, 2019 Apr 23, 2019

Hi Stephen,

also provide something in case someone will press the Cancel button. Then the prompt will return null or undefined.

( function()

{

    if( app.documents.length == 0 ){ return };

    var aDoc = app.activeDocument;  

    var abIdx = aDoc.artboards.getActiveArtboardIndex();

    var abName = prompt( "Rename Active Artboard" + "\n" + "Enter a new name:", "Job Jacket" );

  

    // User pressed the Cancel button:

    if( abName == null ){ return };

  

    aDoc.artboards[abIdx].name = abName;

  

}() )

One should also note that if the prompt returns an empty string, which means not null or undefined, Illustrator will rename the artboard to a default value.

And that depends on the locale of the Illustrator version. My German Illustrator defaults to the name "Zeichenfläche n" where n is a number.

Regards,
Uwe

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 ,
Apr 23, 2019 Apr 23, 2019

Thank you Uwe! I think that this is the 2nd time that I have used the prompt, I was pretty much bluffing my way through from what I had explored using alert. Thank you for extending my knowledge!

Trying this in Photoshop on a layer resize variable, if cancel is pressed then the layer content is removed (I’m guessing that null is not a number).

I found this but have not been able to find a solution:

https://estk.aenhancers.com/8%20-%20ExtendScript%20Tools%20and%20Features/user-notification-dialogs....

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 ,
Apr 24, 2019 Apr 24, 2019

Hi Stephen,

can you point to a discussion in the PhotoShop Scripting Forum concerning Cancel when using a Prompt and removing the layer content as consequence? ( That discussion should be done over there, I think. )

Regards,
Uwe

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 ,
Apr 24, 2019 Apr 24, 2019
LATEST

Thanks Uwe, I just created the topic as this was previously only a personal exercise for learning:

Adding a Prompt to a Variable

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 ,
Apr 18, 2019 Apr 18, 2019

https://forums.adobe.com/people/pixxxel+schubser  wrote

Try that

// set a new name eg "Job Jacket" for the active artboard in active document var aDoc = app.activeDocument; var abIdx = aDoc.artboards.getActiveArtboardIndex (); aDoc.artboards[abIdx].name = "Job Jacket"; // set the new name here

Have fun

Thank you so much!  This is perfect.  Exactly what I needed.  Now I can assign this script a keyboard shortcut and my life is sooo much easier now! 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