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

Script to rename artboards from textbox values?

New Here ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

Hi,

Is there a way to rename all artboards based on the text that occurs in a textbox in a specefic location on the artboard?

Effectively just copying the text to the artboard name.

 

I'm unsure if it's even possible to specify a textbox by location?

if it is would they have to be identical, or can you set a range i.e. 'the textbox that sits between 30-35mm from the top of the board' or similar?

 

Is this overly complicated? would it be easier to compile a list in excel and import into the artboard names somehow instead? Ideally I'd avoid this as I still have to manually create the list.

 

Thanks.

 

TOPICS
Scripting

Views

392

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 1 Correct answer

Enthusiast , Jul 20, 2022 Jul 20, 2022

My script has something similar. If the top object on the artboard is a TextFrame, its contents will be the name of the artboard. If it's a different type of object, its name will be the name of the artboard
https://github.com/creold/illustrator-scripts/blob/master/jsx/RenameArtboardAsTopObj.jsx
RenameArtboardAsTopObj.gif

Votes

Translate

Translate
Adobe
Guide ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

Can you show a screenshot of an example?  

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
New Here ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

Asset 1.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 ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

So you want to have some text on each artboard that sets the artboards name? It can sort of be done in various ways. How about this approach:

1. you make a textFrame item with a 'name' (in the layers panel) of "NAME_ARTBOARD_1".

2. you set the contents of the textFrame to, for example, "Figure A".

3. you repeat steps 2 and 3 for each artboard you wish to name—"NAME_ARTBOARD_2" and "Figure B", etc.

4. run a script that finds all the textFrames from step 1 and names the artboard at index 1, 2, etc. with the contents "Figure A" etc.

That would work, but you'd have to run the script again whenever you made a change. What is your scripting knowledge?

- Mark

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
New Here ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

I have Zero Scripting knowledge, so I was hoping to asses the feasibilty first.

 

For the above, can all the textframes containing the names be on one layer and then auto renamed using something like:

https://community.adobe.com/t5/illustrator-discussions/is-there-a-way-to-batch-rename-artboards-in-i...

 

to give each text frame the 'look-up' name and then run a seperate script that'll pull the value from the object name in the layer and assign it to the artboard?

 

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 ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied


@default60bub5zrveng wrote:

For the above, can all the textframes containing the names be on one layer and then auto renamed using something like:

https://community.adobe.com/t5/illustrator-discussions/is-there-a-way-to-batch-rename-artboards-in-i...

What do you mean "auto renamed"? The scripts in that thread are for speeding up batch artboard renaming. You original request is quite different I thought. At some point in the process you'll have to manually enter all the artboard names *somewhere*. I assumed you would simply enter them in as the contents of the textFrame items, for example in the "Artboard title text frame" text frame in your screenshot.

 

Then script would find the textframe and rename its artboard accordingly. Have I got that wrong?

- Mark

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
New Here ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

Sorry I don't think I followed your original post properly, So looking at the below example can I use a script to pull the values 'Artboard title text 1' etc. and apply that to each artboard name respectively?

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 ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

Yes, that's how I imagined it working.

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
Guide ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

This is based on the "Artboard title text frame" being the bottom-most textframe in an artboard.

var doc = app.activeDocument;
doc.selection = null;
var ABs = doc.artboards;
for (var i = 0; i < ABs.length; i++) {
    ABs.setActiveArtboardIndex(i);
    doc.selectObjectsOnActiveArtboard();
    var frames = [];
    for (var j = 0; j < doc.selection.length; j++) {
        if (doc.selection[j].typename == "TextFrame") {
            frames.push(doc.selection[j])
        }
    }
    frames.sort(function(a, b) {return a.top - b.top;})
    ABs[i].name = frames[0].contents;
}

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
New Here ,
Jul 21, 2022 Jul 21, 2022

Copy link to clipboard

Copied

Thanks, I ended up using Sergey's script below.

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
Enthusiast ,
Jul 20, 2022 Jul 20, 2022

Copy link to clipboard

Copied

My script has something similar. If the top object on the artboard is a TextFrame, its contents will be the name of the artboard. If it's a different type of object, its name will be the name of the artboard
https://github.com/creold/illustrator-scripts/blob/master/jsx/RenameArtboardAsTopObj.jsx
RenameArtboardAsTopObj.gif

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
New Here ,
Jul 21, 2022 Jul 21, 2022

Copy link to clipboard

Copied

LATEST

I'd already come across your work and this is how I ended up doing it as it was easy to have all the names in a single layer and then just lock all other layers and run this script.

 

Thanks for sharing!

 

 

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