Automating Adobe Illustrator with GPT-4: A Scripting Tutorial | Part 01

Let ChatGPT Write Your Illustrator Script

This tutorial shows a practical use of GPT-4 for designers: writing an Adobe Illustrator script that fills in text, sets a date and exports a batch of PNG files, without writing the code yourself. The example is a weekly set of “good morning” social media posts, Monday to Friday, where only the message and the date change. Instead of editing and exporting five files by hand, one script does it in seconds.

This is Part 01 of a three-part series. Part 01 covers the message and date layers and the batch export. Part 02 adds swapping the background image. Part 03, which builds a small user interface for entering the messages and dates, is a members-only video.

How the Illustrator file is set up

The artwork uses three main layers, and the layer names matter because the script finds objects by name:

  • Design layer: the background artwork.
  • Message layer, with a sub text layer named “message”: the good morning message.
  • Date layer, with a sub text layer named “date”: the day and date.

Step 1: Generate the messages

Ask ChatGPT for five good morning messages under 100 characters. You can steer the tone for your industry, for example “make it related to crypto people”. Copy the five results. You will paste them into the script later, and you can regenerate them every week.

Step 2: Write the prompt for the script

Keep the prompt in a separate text file so you can improve it and reuse it. The prompt in the video has three parts:

  1. Describe the file. “I need help creating a script for Adobe Illustrator. I have three main layers: date, message and design. On the date layer there is a sub text layer called date. On the message layer there is a sub text layer called message.” Giving the structure as a list helps.
  2. Add one important line: “Please remember Illustrator layers work differently from Photoshop.” Photoshop scripts from ChatGPT usually work first time; Illustrator scripts often do not, and this line saves a lot of fixing.
  3. Say what you want. Replace the message text with the five messages, set the date text in the format “Monday 22nd May 2023” starting from a given Monday, and save five PNG files at 150 dpi at the original artwork size, next to the original file.

Step 3: Save and run the script

Copy the JavaScript that ChatGPT returns into Notepad and save it with a .jsx extension, for example GM.jsx. In Illustrator go to File > Scripts > Other Script and open the file.

Step 4: Expect an error, and feed it back

The first version in the video fails with “Error 1302: No such element” on line 5. Do not try to debug it yourself. Copy the exact error text and the line number back into ChatGPT. It explained that Illustrator scripting is case sensitive, that the layer and text frame names must match exactly and be unlocked and visible, and it rewrote the script to find the first text frame in each layer and to show a clear alert instead of a raw error. Paste the new code over the old one.

Two small habits from the video: in Windows Notepad use Save As rather than Save, because Save sometimes silently keeps the old code, and keep ChatGPT and Illustrator side by side so you can copy errors quickly.

Step 5: Run again and check the output

The second version works. Illustrator writes five PNG files next to the source file, each with a different message and the correct weekday and date. From now on, the weekly routine is: paste the new messages into the script, change the start date and month, and run it.

Conclusion

The value here is not the script itself but the workflow: describe the file precisely, ask for the exact output you need, and treat error messages as the next prompt. A repetitive export job becomes a one-click task, and the same approach works for any layered Illustrator or Photoshop document with text that changes on a schedule.

Links from the video

Adobe Illustrator, AI, Tutorial
Previous Post
The Rise of AI in the Art World: Threat or Opportunity?
Next Post
AI Meets Photoshop: Generative Fill Explained | Tutorial

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

keyboard_arrow_up