Highlighted

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

Participant ,
Dec 29, 2019

Copy link to clipboard

Copied

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

Adobe Community Professional
Correct answer by brianp311 | Adobe Community Professional

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? 

TOPICS
Scripting

Views

199

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

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

Participant ,
Dec 29, 2019

Copy link to clipboard

Copied

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

Adobe Community Professional
Correct answer by brianp311 | Adobe Community Professional

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? 

TOPICS
Scripting

Views

200

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 29, 2019 0
Adobe Community Professional ,
Dec 29, 2019

Copy link to clipboard

Copied

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? 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 29, 2019 1
Participant ,
Dec 29, 2019

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 29, 2019 0
Adobe Community Professional ,
Dec 29, 2019

Copy link to clipboard

Copied

I've always wanted to visit Vancouver, so I'll take you up on that latte when I do. Cheers!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 29, 2019 0
Community Beginner ,
Jun 26, 2020

Copy link to clipboard

Copied

Hello, brianp311!

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


1941EE06-E10B-417E-B5B2-27721AD65C2F.jpeg

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 26, 2020 0
Adobe Community Professional ,
Jun 27, 2020

Copy link to clipboard

Copied

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 )

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 27, 2020 1
Community Beginner ,
Jun 27, 2020

Copy link to clipboard

Copied

Thanks!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 27, 2020 0