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

Script Illustrator for to create a box with Registration Color

Explorer ,
Jan 26, 2023 Jan 26, 2023

Copy link to clipboard

Copied

Exist that possibility?

TOPICS
Scripting

Views

511

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
Adobe
Community Expert ,
Jan 26, 2023 Jan 26, 2023

Copy link to clipboard

Copied

quote

Exist that possibility?


By @Julio Ricardo

 

Yes. Indeed.
😉



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

Copy link to clipboard

Copied

Try following,

var _doc = app.activeDocument;
var _rect = _doc.pathItems.rectangle(0,0,100,100);
_rect.fillColor = _doc.swatches['[Registration]'].color;
Best regards

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

Copy link to clipboard

Copied

Hi Charu,

nice to read you again.

Please read OP's other questions to understand my slightly ironic answer (although it actually answers the original question exactly).

😉

 

@Julio Ricardo 

Please note that the names of the swatches in scripts may differ depending on the language.

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

Copy link to clipboard

Copied

@pixxxelschubser 

I like the way you answers not only this one but others too 🙂

Simple and precise 🙂

Best regards

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

Copy link to clipboard

Copied

Thank you.
The same goes for your great answers.
😉

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

Copy link to clipboard

Copied

By the way, here is a way that should work in different locales:

function getRegistrationSwatch(doc) {

    for (var i = 0; i < doc.swatches.length; i++)

        if (
            doc.swatches[i].color.typename == 'SpotColor'
            && doc.swatches[i].color.spot.colorType == ColorModel.REGISTRATION
        )
            return doc.swatches[i];

};

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

Copy link to clipboard

Copied

Hi @m1b 

how about

 

//alert(app.activeDocument.swatches[1].name);
alert(app.activeDocument.swatches[1]);

 

 

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

Copy link to clipboard

Copied

@pixxxelschubser - No, we can move the swatch up and down in Swatches panel, so index will get changed.

Best regards

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

Copy link to clipboard

Copied

Charu

You are right. That was hasty of me. I was of the opinion that [None] and [Registration] cannot be removed AND cannot be moved, but only the first is true.


On the other hand, one could certainly try to avoid unnecessary loops and combine both variants - perhaps like this:

 

var aSwatch = app.activeDocument.swatches[1];
if (aSwatch.color.typename == 'SpotColor' && aSwatch.color.spot.colorType == ColorModel.REGISTRATION) { alert("directly found without loop: " + aSwatch); } // no loop through the swatches needed
else {alert("loop was needed and found: " + getRegistrationSwatch(app.activeDocument));}; // then loop with @m1b's function

// by @m1b
function getRegistrationSwatch(doc) {

    for (var i = 0; i < doc.swatches.length; i++)

        if (
            doc.swatches[i].color.typename == 'SpotColor'
            && doc.swatches[i].color.spot.colorType == ColorModel.REGISTRATION
        )
            return doc.swatches[i];

};

 

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
Explorer ,
Jan 30, 2023 Jan 30, 2023

Copy link to clipboard

Copied

LATEST

Hi @Charu Rajput 

 

How apply Registration Color in line the code below:

 

// Create a horizontal line
var horizontalLine = doc.pathItems.add();
horizontalLine.setEntirePath([[centerPoint[0]-6, centerPoint[1]],[centerPoint[0]+6, centerPoint[1]]]);
horizontalLine.stroked = true;
horizontalLine.strokeColor = new CMYKColor();
horizontalLine.strokeColor.cyan = 0;
horizontalLine.strokeColor.magenta = 0;
horizontalLine.strokeColor.yellow = 0;
horizontalLine.strokeColor.black = 100;
horizontalLine.strokeWidth = 0.4;

 

Tks

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