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

Script Illustrator for to create a box with Registration Color

Explorer ,
Jan 26, 2023 Jan 26, 2023

Exist that possibility?

TOPICS
Scripting
926
Translate
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
quote

Exist that possibility?


By @Julio Ricardo

 

Yes. Indeed.
😉



Translate
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

Try following,

var _doc = app.activeDocument;
var _rect = _doc.pathItems.rectangle(0,0,100,100);
_rect.fillColor = _doc.swatches['[Registration]'].color;
Best regards
Translate
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

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.

Translate
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

@pixxxelschubser 

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

Simple and precise 🙂

Best regards
Translate
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

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

Translate
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

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];

};
Translate
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

Hi @m1b 

how about

 

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

 

 

Translate
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

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

Best regards
Translate
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

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];

};

 

Translate
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
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

Translate
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