MixedInksGroup Javascripting?
Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / MixedInksGroup Javascripting?
- This topic has 5 replies, 3 voices, and was last updated 4 years, 2 months ago by Mahesh Thambe.
-
AuthorPosts
-
-
January 17, 2020 at 11:40 am #1223378Antoine DubucMember
Hello again,
I’m writing a tool that lets you create and set on page swatches of any size and different shapes.
It’s mainly to do mixed inks for use with the Xerox Iridesse Press, but you could create a Pantone Book with it I guess.I’ve achieved so far, thanks to the help of others, the ability to create a bunch of mixed inks and create the rectangles on the page.
I would to create groups for mixed inks, to tidy things up a little.
I don’t know.I’m not yet a good enough programmer to figure it out from this webpage: https://www.indesignjs.de/extendscriptAPI/indesign-latest/#MixedInkGroups.html
Anyone can help me thank you!
-
January 17, 2020 at 12:11 pm #14323265Mahesh ThambeMember
Hello,
MixedInkGroups.add lets you generate multiple mixed inks (from a combination of inks), as done in UI by Swatches > New Mixed Ink Group.
inkList – inks to use to create the mixed inks
inkPercentages – Array of initial percentages for each ink from inkList
repeatValues – Array of repetitions for each ink
incrementValues – Array of increments to use when repeatingFor example,
[Proces Cyan, PANTONE 281 C] with percentages [0, 0], repeatValues [2, 2], ad increments [10, 10] would create (2 + 1) x (2 + 1) = 9 mixed inks.Cyan %, PANTONE 281 C %
(0, 0)
(0, 10)
(0, 20)
(10, 0)
(10, 10)
(10, 20)
(20, 0)
(20, 10)
(20, 20)Hope this helps.
Regards,
MT -
January 17, 2020 at 12:12 pm #14323264Theunis De JongMember
At the bottom of that page you can see that this object is used in both Application (adding one in there adds it to the default set of swatches), and Document.
Presumably (untested) you can use
myMixGroup = app.activeDocument.mixedInkGroups.add (... your parameters here ..)
and then use that variable where you wish.
-
January 17, 2020 at 12:23 pm #14323261Antoine DubucMember
Wow! Thank you for replying.
Here’s a link if you want to take a peek :)
https://1drv.ms/u/s!AqGk3glzqCRRrQrm4SvweIdKy__y?e=lmgTBTHere’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/cq5kaF3I 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.” );
}
}}
-
January 17, 2020 at 12:44 pm #14323260Mahesh ThambeMember
Yes, MixedInkGroups and ColorGroups are different things.
To add a mixed ink (or any swatch for that matter) to a ColorGroup, you can do:var mixedInkSwatch = // as created in your code
app.activeDocument.colorGroups.add(“My Mixed Inks”, [mixedInkSwatch]);Regards,
MT -
January 17, 2020 at 2:44 pm #14323259Antoine DubucMember
Thank you Mahesh!! Hey, and a good weekend to all :)
-
-
AuthorPosts
- You must be logged in to reply to this topic.