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

135

Likes

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

Participant , 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

Likes

Translate

Translate
Advisor ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

Can you show a screenshot of an example?  

Likes

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

Likes

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
Adobe Community Professional ,
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

Likes

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?

 

Likes

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
Adobe Community Professional ,
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

Likes

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?

Likes

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

Copy link to clipboard

Copied

Yes, that's how I imagined it working.

Likes

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
Advisor ,
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;
}

Likes

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.

Likes

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
Participant ,
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

Likes

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!

 

 

Likes

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