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

Illustrator script: apply swatch from library

Community Beginner ,
Sep 13, 2018 Sep 13, 2018

Copy link to clipboard

Copied

Hi,

I'm working on a script to apply a swatch from a library to a pathItem and the color name to a textFrame.

It works, the problem is it crashes when I close the file with the PMS Library. Any help would be very appreciated.

Here is my code.

#target Illustrator

var docRef = app.activeDocument;

var docRef1 = app.open(File("~/Documents/PMSLibrary.ai"));

  // Get specific swatch

  var PMSColor = docRef1.swatches.getByName('PANTONE 100 C');

  // Add Swatch to Original Document

  var AddColor = docRef.swatches.add();

  AddColor.name = PMSColor.name;

  AddColor.color = PMSColor.color

  // Add text frame and pathItem

  var ColorFrame = docRef.textFrames.add('Color')

  var ColorBox = docRef.pathItems.add('Box')

  // Assign to Text Frame

  ColorFrame.contents = PMSColor.name

  // Assign color to PathItem

  ColorBox.fillColor = PMSColor.color

  // Close reference document

  docRef1.close(SaveOptions.DONOTSAVECHANGES);

  app.redraw();;

Thanks!

TOPICS
Scripting

Views

2.4K

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

Valorous Hero , Sep 13, 2018 Sep 13, 2018

try to apply the color to a temp path item, which you can then duplicate into your other document. Then close the library doc and see if it still crashes?

Votes

Translate

Translate
Adobe
Valorous Hero ,
Sep 13, 2018 Sep 13, 2018

Copy link to clipboard

Copied

try to apply the color to a temp path item, which you can then duplicate into your other document. Then close the library doc and see if it still crashes?

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 Beginner ,
Sep 13, 2018 Sep 13, 2018

Copy link to clipboard

Copied

That worked, thanks a lot!

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 Beginner ,
Mar 18, 2020 Mar 18, 2020

Copy link to clipboard

Copied

How to duplicate the swatches in script?

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 ,
Mar 19, 2020 Mar 19, 2020

Copy link to clipboard

Copied

LATEST

1. get a ref of the swatch you want to duplicate

2. add a new swatch

3. apply ref swatch color in step 1 to new swatch

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