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

Script to rename artboards from textbox values?

New Here ,
Jul 19, 2022 Jul 19, 2022

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
768
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

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

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

Can you show a screenshot of an example?  

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

Asset 1.png

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

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

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

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?

 

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

@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

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

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?

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

Yes, that's how I imagined it working.

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

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

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

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

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

 

 

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