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

JS Convert Spot Colours to process

New Here ,
Sep 19, 2008 Sep 19, 2008
Help, I'm very new to Javascript. I would like to know to write a Javascript which would convert any spot colours into process colours in Adobe illustrator. Can any help... please.

Cheers Chris
TOPICS
Scripting
3.2K
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 ,
Sep 19, 2008 Sep 19, 2008
If the purpose is to print color separations, you can do so by setting the parameter convertSpotColors under PrintColorSeparationOptions to TRUE. See p. 149 of the AI CS3 JS Reference.
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
New Here ,
Sep 20, 2008 Sep 20, 2008
Hi, I can't rely on the other end doing this when they print so I felt that if I ran a script that could convert any swatch to process if they were spot would be safer!

Below is my very poor attempt!! I no what the name of the colour is in the Swatches palette

Cheers Chris

if ( app.documents.length > 0 ) {
getByName (Spanish Rojo) = app.activeDocument.swatches[0];
var colorType = colorType.PROCESS
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
LEGEND ,
Sep 20, 2008 Sep 20, 2008
You've got syntax and/or reference errors in every line except the first:

> if ( app.documents.length > 0 ) {

You've opened a conditional statement block: If there is more than one document....

> getByName (Spanish Rojo) = app.activeDocument.swatches[0];

You've typed the name of a method of the swatches object but have not told Javascript which object getByName is a method of. Even if you had included the method's object, you did not put the string parameter in quotes. Javascript doesn't recognize the start of this line as a method and tries to read it as a declaration of a variable named "getByName". But it encounters the space and expects a semicolon, because it sees giberish, "(Spanish Rojo)" before it sees the assignment operator.

If that did work, your line would create a variable and assign it a reference to the object which is the first swatch in the document (Swatch[None]).

> var colorType = colorType.PROCESS

You've declared a variable named "colorType". colorType is a property of the spot object, but you are using it here as the name of a new variable. Then you typed the assignment operator (=). So Javascript is trying to assign your variable, colorType, a value of colorType.PROCESS. But colorType.PROCESS is not in quotes. So Javascript thinks it's a reference to an object or an object property. There is no object or object property named "colorType.PROCESS" in the entire AI Javascript Reference. (Do a search.) You also did not end this statement with a semi-colon.

You also didn't close (}) your conditional block.

Try this for a start:

if ( app.documents.length > 0 ) {
var colorToChange = app.activeDocument.swatches.getByName ("Spanish Rojo");
var CMYKvalues=colorToChange.color.spot.color;
colorToChange.color=CMYKColor;
colorToChange.color=CMYKvalues;
}

The above assumes a CMYK document, with a spot color Swatch named "Spanish Rojo".

To build a script that changed any spot color Swatch in a CMYK document to CMYK process, you'd probably want to run something like the above inside a for() loop that cycles through all the Swatches, checking each to determine whether it is a spot color, and then executing the change if it is--instead of looking for Swatches of a particular name.

JET
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
New Here ,
Sep 20, 2008 Sep 20, 2008
Thanks JET, I have learnt a lot from this.

The last bit you talk about a script that would change any spot colour to process, how would that look? I didn't get the bit below

"above inside a for() loop that cycles through all the Swatches"

Once again thanks for your help and time, It's great to have help from people like you.

Cheers Chris
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
New Here ,
Sep 21, 2008 Sep 21, 2008
Still can't work out how to build a script that changes any spot color Swatch in a CMYK document to CMYK process using the () loop that cycles through all swatches.

Any chance of explain a bit more for me.

Cheers Chris
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
LEGEND ,
Sep 21, 2008 Sep 21, 2008
Try this:<br /><br />if(app.documents.length>0){<br /><br />var docRef=app.activeDocument;<br /><br />for(i=0;i<docRef.swatches.length;i++){<br /><br />var currSwatch=docRef.swatches;<br /><br />if(currSwatch.color.typename=="SpotColor"){<br /><br />var CMYKvalues=currSwatch.color.spot.color;<br /><br />currSwatch.color=CMYKColor;<br /><br />currSwatch.color=CMYKvalues;<br /><br />}<br /><br />}<br /><br />}<br /><br />Test thoroughly.<br />Use at your own risk.<br />No warranties, express or implied.<br /><br />;-)<br />JET
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
LEGEND ,
Sep 21, 2008 Sep 21, 2008
LATEST
Chris,

I think you will find that the script above does indeed change any spot color Swatch to CMYK process.

However, it does not change to CMYK process the colors of artwork on the page to which the spot colors were applied.

Well, sort of. Follow these steps carefully and exactly:

1. Create a document with a a spot color Swatch. Name the Swatch MySpotColor.

2. Rectangle tool: Draw a rectangle. Fill it with the spot color Swatch. Leave the rectangle selected.

3. Open the Color Palette. Note that the palette shows the single tint slider, the Spot Color indicator, and the CMYK indicator. The name of the Swatch is shown under the tint slider.

4. Mouse over (but do not click) the Spot Color indicator. Note that the tooltip reads "Spot Color (Click to convert)". If you click the indicator (don't), the object's fill would be changed to a process fill.

5. Run the script. The spot color Swatch becomes CMYK process. Look at the Swatches Palette. Note that the MySpotColor Swatch is not highlighted, even though the rectangle is still selected, and even though Spot Colors are always Global, and Global Colors, by definition, are supposed to update changes to objects to which they have been applied.

Look at the Color Palette. Note that the Spot Color indicator is gone, and has been replaced with the Global Swatch indicator. However, also note that only the single tint slider is shown, which would indicate that the color of the rectangle is still a Spot Color. In fact, if you now print the page to PDF as separations, you will see that you still get a Spot Color plate. Also note that the name of the former Spot Color Swatch is gone. There is no name at all.

However, mouse over (don't click) the Global Swatch indicator, and note that the tooltip reads "Process Color (Click to Convert)".

6. Drag that color swatch from the Color Palette and drop it in the Swatches Palette. Note that a process (not spot) Swatch is created. Note that the new Swatch is not highlighted, despite the fact the rectangle is still selected, and the color (according to the Color Palette) is supposed to be Global.

7. From the Color Palette's flyout menu, select "Create New Swatch". Note that the New Swatch dialog wants to create a Spot Color swatch, and its name is "MySpotColor 2".

8. Click OK. Note that the new Swatch is created and is highlighted, and that the Color Palette now shows MySpotColor 2 under the tint slider.

What's going on here? Well, at first blush, it appears that when changing a color from spot to process via Javascript, Illustrator does not abide by the change regarding what is supposed to be the definition of a Global Swatch.

But I think it's more. I strongly suspect this is a bug; and another manifestation of the similar issue I noted in this post regarding apparent confusion on AI Javascript's part about what spot colors are as opposed to global colors. (Do a search for "global" in the AICS3 Javascript Reference, and you'll find no reference to global swatches.)

I think either AI's Javascript is screwed up here, or Illustrator is, or they both are.

I have always thought that AI's whole "Global Swatch" scheme is screwed up. All Swatches should be what AI calls "global".

JET
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