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
  • 6276 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

renél80416020
renél80416020Correct answer
Inspiring
April 16, 2019

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

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