Skip to main content
Das Boomer
Known Participant
December 29, 2019
Answered

Script -> Polygon -> fillColor -> MixedInk -> Nope.

  • December 29, 2019
  • 2 replies
  • 847 views

Greetings,

 

This is my third question this weekend, and ever, and I apologize for posting so much. I do only post after hours of research so please be kind!

 

My question is how to assign a mixed ink to a polygon (fillColor)?

 

 I can create a polygon and assign it a spot or a cmyk fine using the following code:

var poly = page.polygons.add({geometricBounds:[y1,x1,y2,x2],numberOfSides:6, fillColor: mySpot});

The spot or cmyk were created like this:

var myCMYK = doc.colors.add();
myCMYK.properties = {name: "test", model: ColorModel.PROCESS, space: ColorSpace.CMYK, colorValue:[80,50,30,10] };
var myLAB = doc.colors.add();
myLAB.properties = {name: "myLAB", model: ColorModel.PROCESS, space: ColorSpace.CMYK, colorValue:[80,50,30,10] };

The mixed ink was a bit more involved and is created this way:

var MY_MIX_INKS = { 'Process Cyan': 0, 'Process Magenta' : 0, 'Process Yellow': 100, 'Gold'   : 60}, MY_MIX_NAME = 'mixed';
 
// Ink Validator
// -------------------------------------
var validateInkData = function(o, c, ll, pp) {
    var k, t, z=0, r=1;
    ll.length = pp.length = 0;
    for( k in o )
        {
        if( !o.hasOwnProperty(k) ) continue;
        if( !(t=c.itemByName(k)).isValid ){ r=0; break; }
        ll[z] = t.getElements()[0];
        pp[z++] = +o[k];
        }
    return r;
    };
// Main Code
// -------------------------------------
var doc = app.activeDocument,
    inkList,    // will receive validated ink list (array)
    inkPerc;    // corresponding percentages (array)
 
if( !doc.mixedInks.itemByName(MY_MIX_NAME).isValid )
    {
    if( validateInkData(MY_MIX_INKS,
        doc.inks, inkList=[], inkPerc=[]) )
        {
        doc.mixedInks.add(inkList, inkPerc,
            {
            name: MY_MIX_NAME,
            model: ColorModel.MIXEDINKMODEL,
            space: ColorSpace.MIXEDINK
            });
 
     /*   alert( "The mixed ink '" + MY_MIX_NAME +
            "' has been successfully created." );*/
        }
    else
        {
        alert( "Unable to create mixed ink. " +
            "Some inner inks are missing." );
        }
    }
else
    {
    alert( "The mixed ink '" + MY_MIX_NAME +
        "' already exists." );
    }

 

But no matter what I try to write for that fill color, no matter that the mixed ink does show up in the swatches list in InDesign, ExtendScript always error out at that first line of the polygon creation.

var poly = page.polygons.add({geometricBounds:[y1,x1,y2,x2],numberOfSides:6, fillColor: mixed});

To me, being inexperienced, and under pressure, it looks like there's some undocumented way of pulling this off, or there's a bug in there.

 

Any assistance is appreciated!!!

 

Cheers from Vancouver,

 

Antoine

This topic has been closed for replies.
Correct answer brian_p_dts

Have you tried putting quotes around "mixed" in your add function? fillColor accepts with a string or swatch, so you would pass it the swatch string name (just "mixed") or doc.swatches.itemByName("mixed")

 

Edit: What error are you getting? 

2 replies

June 27, 2020

Hello, brianp311!

Do you know how to activate the Global option on Swatch options in Illustrator using a Script?


Community Expert
June 27, 2020

Hi Rob,

you better ask this over in the Adobe Illustrator forum:

https://community.adobe.com/t5/illustrator/bd-p/illustrator?page=1&sort=latest_replies&filter=all

 

Or look through the Adobe Illustrator DOM description by Gregor Fellenz (version 21):

https://www.indesignjs.de/extendscriptAPI/illustrator21/#about.html

 

Thanks,
Uwe Laubender

( ACP )

June 27, 2020

Thanks!

brian_p_dts
Community Expert
brian_p_dtsCommunity ExpertCorrect answer
Community Expert
December 29, 2019

Have you tried putting quotes around "mixed" in your add function? fillColor accepts with a string or swatch, so you would pass it the swatch string name (just "mixed") or doc.swatches.itemByName("mixed")

 

Edit: What error are you getting? 

Das Boomer
Known Participant
December 30, 2019

Brian, I think I owe you a latte or something.

I had, I would swear, tried both. But just now the double quotes worked.

Wow, getting into something new isn't easy past forty, especially with a cold!

Thank you kindly, much appreciated, Brian.

 

Antoine

brian_p_dts
Community Expert
Community Expert
December 30, 2019
I've always wanted to visit Vancouver, so I'll take you up on that latte when I do. Cheers!