Skip to main content
Participant
March 29, 2019
해결됨

pathItem color name

  • March 29, 2019
  • 1 답변
  • 473 조회

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

이 주제는 답변이 닫혔습니다.
최고의 답변: 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 답변

Silly-V
Silly-V답변
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();