Skip to main content
Participant
March 29, 2019
Answered

pathItem color name

  • March 29, 2019
  • 1 reply
  • 473 views

How can I get pathItem fillcolor name (name of swatch color).?

This topic has been closed for replies.
Correct answer Silly-V

You have to select stuff, but here's how I am able to make it work- try it:

(You must have a document with one path in it.)

#target illustrator

function test(){

     var doc = app.activeDocument;

     doc.selection = null;

     var pathArtItem = doc.pathItems[0];

     pathArtItem.selected = true;

     var selectedSwatches = doc.swatches.getSelected();

     if (selectedSwatches.length) {

     var first_andShouldBeOnly_SelectedSwatch = selectedSwatches[0];

          alert("The name of the selected swatch for this path is '" + first_andShouldBeOnly_SelectedSwatch.name + "'");

     } else {

          alert("No swatches were found to be selected when the art ite was selected.");

     }

};

test();

1 reply

Silly-V
Silly-VCorrect answer
Legend
March 29, 2019

You have to select stuff, but here's how I am able to make it work- try it:

(You must have a document with one path in it.)

#target illustrator

function test(){

     var doc = app.activeDocument;

     doc.selection = null;

     var pathArtItem = doc.pathItems[0];

     pathArtItem.selected = true;

     var selectedSwatches = doc.swatches.getSelected();

     if (selectedSwatches.length) {

     var first_andShouldBeOnly_SelectedSwatch = selectedSwatches[0];

          alert("The name of the selected swatch for this path is '" + first_andShouldBeOnly_SelectedSwatch.name + "'");

     } else {

          alert("No swatches were found to be selected when the art ite was selected.");

     }

};

test();