Skip to main content
Participating Frequently
April 12, 2019
Answered

How can I change ALL active document swatches from COLOUR TYPE - Process Colour to SPOT

  • April 12, 2019
  • 2 replies
  • 6303 views

Hi all,

This is my first foray into a forum, can anyone help?

I receive Autocad DWG dieline files (Saved in Autocad 2010 format) that I open directly into Illustrator. (Right click - open)

As part of my workflow I have to change all swatches in the active document to Spot colours.

The Operating system I'm using is Windows 10.

I'm using Illustrator 2019.

Can anyone offer any guidance or a solution on how I can automate this?

I use Illustrator actions a lot, but have never attempted to write any scripts yet -

but I feel I may need to on this one as actions commands don't seem to do do what I need.

All suggestions, guidance or scripts that can do this will be greatly appreciated.

Many thanks in advance.

Daryl.

This topic has been closed for replies.
Correct answer renél80416020

Bonjour darylt44382031 ,

Je n'ai jamais été un fan d' AutoCad, trop complexe pour mes neurones mais j'avais conservé des documents DWG

sur un vieux disque dur (1992).

J'ai utilisé ENGIN.DWG pour faire un test, Le Cloud d'Orange
je suis parti dans une mauvaise direction avec :

  var swatch= activeDocument.swatches["AutoCAD Color 2"]

        swatch.colorType = ColorModel.SPOT;

qui ne donnait aucun résultat.

J'ai donc fait un script qui crée de nouvelles couleurs .SPOT à partir des couleurs existantes

et attribuer les nouvelles couleurs  correspondantes à chaque tracé.

Enfin supprimer les couleurs d'origine.

Comme la nuit porte conseil, le lendemain matin j'avais la solution que voici :

// JavaScript Document pour Illustrator

//processtospot_01.js

//Mon, 15 April 2019 09:00:59 GMT

// elleere Landry René

// Pour le document actif [0]

// convertir des spotColor Quadri (ColorModel.PROCESS) en Ton direct (ColorModel.SPOT)

// provenant d'AutoCAD Color Couleurs RVB

//-----------------

function processtospot() {

  var Spots, nbSpot,spt, swathsColorType;

      Spots = app.activeDocument.spots;

      nbSpot = Spots.length; //alert(nbSpot)

        for (var i = 0;  i < nbSpot; i++) {

          spt = Spots;

          swathsColorType = spt.colorType;

          //alert("swathColorType = "+swathsColorType);

            if (swathsColorType == ColorModel.PROCESS) {

              spt.colorType = ColorModel.SPOT;

            }

        }

}

//-----------------

if (app.documents.length) processtospot();

Si d'autres questions, me contacter par mail

De elleere

2 replies

renél80416020
Inspiring
April 15, 2019

Bonjour darylt44382031

Tu veux obtenir cela ? si oui, j'ai la solution.

Participating Frequently
April 16, 2019

Bonjour Renel,

Thank you for your reply and your time to help me with my challenge.

If you have a script that has found the RVB colour and is then ready for me to add my own name, then this may work for me.

Are you able to share how you achieved this solution with me?

Regards

Daryl

Community Expert
April 24, 2019

Hi Daryl,

as renél80416020 is showing, Illustrator's spot colors do not meet your expectations.

Some values are rounded if you look from the perspective of the UI.

That means:

1. Either you will round the values before you can do comparisons.

2. Or you rely on the unrounded values and implement them in your data set.

Option 2 might be unreliable, because you cannot be sure that the imported spots are always exactly the same.

Or Illustrator will round after the 12th digit after the dot and will do that differently with a different sample.

As I can see from your data set, there should be no error unless there is already a spot that you cannot rename that corresponds with an entry from the data set.

A function could be done that uses the next nabour of an existing spot's color value and apply the corresponding name.

Regards,
Uwe


If you loop all spot colors of your sample document and gather names and color values you see that two spots share the same color values. That special case is the cause of your error, I think. Spot named [Registration] cannot and should not be renamed.

AutoCAD Color    0,0,0

AutoCAD Color 10    127.000000029802,127.000000029802,255

AutoCAD Color 11    255,191.000003814697,127.000000029802

AutoCAD Color 12    255,255,0

AutoCAD Color 13    153.000006079674,102.000001519918,204.000003039837

AutoCAD Color 14    200.000003278255,168.000005185604,90.0000022351742

AutoCAD Color 15    204.000003039837,102.000001519918,0

AutoCAD Color 16    128.00000756979,128.00000756979,128.00000756979

AutoCAD Color 2    255,0,0

AutoCAD Color 3    0,153.000006079674,0

AutoCAD Color 4    255,0,255

AutoCAD Color 5    127.000000029802,255,0

AutoCAD Color 6    0,153.000006079674,204.000003039837

AutoCAD Color 7    0,255,255

AutoCAD Color 8    114.000000804663,0,153.000006079674

AutoCAD Color 9    153.000006079674,0,204.000003039837

[Registration]    0,0,0

Regards,
Uwe

Silly-V
Legend
April 12, 2019

So what is the method by which you convert all the colors to spots?

Do you have regularly-repeating colors which you can count on and a library of swatches, so you can use Recolor art feature?

I'm not exactly sure if that could be recorded as an action any kind of preset - which would if possible allow some sort of action automation in that regard - but assuming it's all non-recordable if this is a method you use then at least there's a starting point.

Participating Frequently
April 14, 2019

Hi Silly-V

I currently have to double click each individual swatch colour then select "spot colour" from the colour type menu. I've just found that I can shift select all swatches and then change the properties of all selected - using the same method which IS an improvement - but I'd still love the script if it could do it all!

In respect to colours - the layers used in autocad have colours associated with them on import; however the names of each layer (in autocad) get lost in translation somewhere between autocad and illustrator.

Layer names translate differently each time - but always appear in Illustrator in the format: AUTOCAD Colour 1,2,3 etc.

The only common translation between autocad and illustrator I have found is the RGB colour.

My Ideal world is to have a script that selects each swatch individually by an RGB attribute, then using that RGB attribute - the scrip would first change the "colour type" to "spot colour" then secondly change the "swatch Name" from whatever it has been named - to a logical name for that layer. eg: "cut" or "crease".

Autocad Layer names are changed on import into illustrator described above - however colours for the autocad layers always import with the following RGB values below:

LAYER NAME - RGB VALUES

Cut layer - 255,0,0

Crease   - 0,153,0

Bleed - 0,127,255

Dimensions - 0,255,0

Unprinted zone - 255,0,255

Lines - 0,0,0

Construction - 255,255,0

Corner datum - 0,255,255

10mm cut/crease - 0,0,255

2 x 2mm perforations - 254,191,16

The above layer list can vary sometimes, eg - sometimes there will be more or sometimes less layers.

it all depends upon the dieline requirements, the layers listed are the main ones used.

I don't know if it is possible for a script to do this
(including the chance that some layers may be present or not) ?

but if it was, this would save me the task of repeatedly doing this routine for every drawing I import.

I'd welcome your thoughts.

Thanks

Daryl