Skip to main content
Participant
October 19, 2018
Question

Convert CMYK process to RGB spot

  • October 19, 2018
  • 2 replies
  • 469 views

I'm a relative novice when it comes to scripting, so I've been trying to scrape together the code I need from here and other sources but it isn't quite doing what I want it to do.

 

I have CMYK icon files that contain 2 global swatches I need to convert to RGB and change the colour values, whilst also converting to spot colours from process. Lastly, I need to rename the 2 swatches. One script I have started is;

var docRef = activeDocument; 

     app.executeMenuCommand('doc-color-rgb');

   

var currentSwatchColor = docRef.swatches['CMYK Colour One'].color.spot.color;

     currentSwatchColor.red = parseInt(20);

     currentSwatchColor.green = parseInt(20);

     currentSwatchColor.blue = parseInt(20);

     currentSwatchColor.colorType = ColorModel.SPOT;

     currentSwatchColor.spotKind = SpotColorKind.SPOTRGB;

This changes the CMYK colour swatch to the specific RGB I need but doesn't make it a spot.

To rename the swatches I have;

for (var i = 0; i < documents.length; i++) {

for (var myCounter = 0; myCounter < docRef.spots.length; myCounter++) {

        docRef.spots[myCounter].locked = false;

        docRef.spots[myCounter].name = docRef.spots[myCounter].name.split('CMYK Colour One').join('RGB Colour One');

         }

}

The above works to rename the swatch but I'm guessing it's not the most simple or elegant way to do it - I found it elsewhere and it works.

One thing I haven't been able to find a solution to is renaming the existing filename, going from "CMYK XXX" to "RGB XXX" in the same file location.

Any help would be much appreciated!

This topic has been closed for replies.

2 replies

renél80416020
Inspiring
October 24, 2018

Salut !

I can do this script, my details are under my profile picture.

de elleere

Disposition_Dev
Legend
October 22, 2018

It may be easier to create new swatches with the desired properties, then select all of the items that contain the old fill or stroke color and apply the newly created one.