Wow! Thank you for replying.
Here’s a link if you want to take a peek :)
https://1drv.ms/u/s!AqGk3glzqCRRrQrm4SvweIdKy__y?e=lmgTBT
Here’s also my working code for swatch generation.
If I change my code to mixedInkGroups instead of mixedInks
It adds some weird looking duplicate (I’m sorry never seen this, don’t know what they are).
Look here: https://imgur.com/cq5kaF3
I want to generate the mixed inks but add them to a color group.
Maybe I’m misunderstanding what a mixedInkGroup is???
THANK you for your time !!
Antoine
//——————————————————————————————————————————————————–ADD SWATCHES TO THE SWATCHES PANEL—————————————————————-
function addSwatchesToPanel(swatches)
{
for(i = 0; i < swatches.length; i++)
{
addMixedInk(parseInt(swatches[i].cyan), parseInt(swatches[i].magenta), parseInt(swatches[i].yellow), parseInt(swatches[i].black), parseInt(swatches[i].specialty), swatches[i].name);
}
}
//——————————————————————————————————————————————————–ADD SWATCHES TO THE SWATCHES PANEL ONE BY ONE—————————————————————-
function addMixedInk(cyan, magenta, yellow, black, specialty, mixedInkName)
{
$.writeln(cyan + ” ” + magenta+ ” ” + yellow+ ” ” + black+ ” ” + specialty+ ” ” + mixedInkName);
var MY_MIX_INKS = {};
MY_MIX_INKS = {
// Valid ink names are required
// At least 2 process inks are required
‘Process Cyan’ : cyan, // Process1 : %
‘Process Magenta’ : magenta, // Process2 : %
‘Process Yellow’ : yellow,
‘Process Black’: black, // Custom1 : %
‘Silver’ : specialty // Custom2 : %
},
MY_MIX_NAME = mixedInkName;
// 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 )
{
$.writeln(k);
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
});
}
else
{
alert( “Unable to create mixed ink. ” +
“Some inner inks are missing.” );
}
}
}