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

I am looking for a script to help me with a common daily task that I do in illustrator 2022

Community Beginner ,
Jan 12, 2023 Jan 12, 2023

Copy link to clipboard

Copied

https://www.dropbox.com/sh/ywb2aizjwyjpzcg/AAAl846MJlQzGemYyWFfcfEAa?dl=0

Above is a dropbox link of the eps keyline file and the script i got off a different Adobe forum, I have made some adjustments to the script to suit my keyline colours but it is still giving me errors. I am looking to run a script that creates new layers in my opened illustrator keyline file and grabs the spot colours and the CMYK Colours onto their own seperate layers eg below.

I would like the script to create the below layers for the relevant colours

Layer Name = Cut for the spot Colour "Artios_Cut"

Layer Name = Crease for the spot Colour "Artios_Crease"

Layer Name = Dimensions for the spot Colour "Artios_Dimensions and text"

All the rest of the artwork can be left on a Layer called "Annotation"

 

I would really love a solution to this daily task so any help would be really appreciated.

Graham

TOPICS
Scripting

Views

271

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

Guide , Jan 17, 2023 Jan 17, 2023

This has not been rigorously tested,  but it should

  1. create a layer (if one does not pre-exist) for every spot color swatch; and
  2. move items with the same spot or CMYK color to the layer in question.  (Items with no corresponding spot color swatch stay where they are.)

 

app.selection = null;
var doc = app.activeDocument;
for (var i = 2; i < doc.swatches.length; i++) {
    if (doc.swatches[i].color.typename == "SpotColor") {
        try {
            var layer1 = doc.layers[doc.swatches[i].name];
    
...

Votes

Translate

Translate
Adobe
Guide ,
Jan 14, 2023 Jan 14, 2023

Copy link to clipboard

Copied

I suspect you haven't gotten replies because your post is unclear.  You talk about "grab(bing) ... colours ... onto ... layers".  What I suspect you mean is that you want to move same-color items onto their own layer.  Is this the case? 

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 ,
Jan 17, 2023 Jan 17, 2023

Copy link to clipboard

Copied

Hi femkeblanco,

Yes by grab I mean "select and move". I suppose the essence of what I need is a script that creates the specific layers I have said in the previous post, ie - "Cut" and if the same script could select a specific spot colour stroke called "Artios_Cut" and move it to this layer.

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
Guide ,
Jan 17, 2023 Jan 17, 2023

Copy link to clipboard

Copied

This has not been rigorously tested,  but it should

  1. create a layer (if one does not pre-exist) for every spot color swatch; and
  2. move items with the same spot or CMYK color to the layer in question.  (Items with no corresponding spot color swatch stay where they are.)

 

app.selection = null;
var doc = app.activeDocument;
for (var i = 2; i < doc.swatches.length; i++) {
    if (doc.swatches[i].color.typename == "SpotColor") {
        try {
            var layer1 = doc.layers[doc.swatches[i].name];
        } catch(e) {
            var layer1 = doc.layers.add();
            layer1.name = doc.swatches[i].name;
        } finally {
            doc.defaultFillColor = doc.swatches[i].color.spot.color;
            move("Find Fill Color menu item");
            doc.defaultFillColor = doc.swatches[i].color;
            move("Find Fill Color menu item");
            doc.defaultStrokeColor = doc.swatches[i].color.spot.color;
            move("Find Fill Color menu item");
            doc.defaultStrokeColor = doc.swatches[i].color;
            move("Find Stroke Color menu item");
        }
    }
}
function move(command) {
    app.executeMenuCommand(command);
    for (var j = 0; j < doc.selection.length; j++) {
        doc.selection[j].moveToEnd(layer1);
    }
    app.selection = null;
}​

 

 

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 ,
Jan 22, 2023 Jan 22, 2023

Copy link to clipboard

Copied

LATEST

Hi femkeblanco,

Thanks so much for this piece of code, it worked a treat,  I really appreciate the effort, much appreciated.

Graham.

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