Copy link to clipboard
Copied
Exist that possibility?
Copy link to clipboard
Copied
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;
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).
š
Please note that the names of the swatches in scripts may differ depending on the language.
Copy link to clipboard
Copied
I like the way you answers not only this one but others too š
Simple and precise š
Copy link to clipboard
Copied
Thank you.
The same goes for your great answers.
š
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];
};
Copy link to clipboard
Copied
Hi @m1b
how about
//alert(app.activeDocument.swatches[1].name);
alert(app.activeDocument.swatches[1]);
Copy link to clipboard
Copied
@pixxxelschubser - No, we can move the swatch up and down in Swatches panel, so index will get changed.
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];
};
Copy link to clipboard
Copied
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