jsx script illustrator - replace items color with a corresponding swatch pattern
I am attempting to create a script to replace all the colors in a picture with a number pattern. I have created a script but it does not work as intended.
The picture is coloured with swatches and need to be replaced by a swatch with the same name but for a "." at the end, i.e. all items of colour Bh will need to be replaced with Bh. pattern.
doc = activeDocument,
swatches = doc.swatches,
items = doc.pathItems;
var correspondingSwatch;
for (var c = 0; c < swatches.length; c++) {
correspondingSwatch = null
for (var i = 0; i < swatches.length; i++) {
if (swatches.name == swatches
}
if (correspondingSwatch != null) {
for (var i = 0; i < items.length; i++) {
if (items.fillColor == swatches
}
}
}
The first and second for loop work as intended but the third for loop does not.
(items.fillColor == swatches
(items.fillColor = correspondingSwatch.color) i want this to fill in the item with the correspondingSwatch pattern, not the color. However I do not know the syntax to use a swatches color to paint an item.
Thank you any one who gives this a read, i am familiar with programming but am just starting on adobe illustrator scripting.
If you could change the code and send it back that would be great, or even telling me what methods or variables to use.
