I am attempting to take a path item that is on its own layer and change its color multiple times, saving it each time.
I was able to do it with javascript however can’t get it to work in applescript.
Javascript:
(Items are already selected that I intend to change.)
var iL = app.activeDocument.pathItems.length;
var colorSwatches = app.activeDocument.swatchGroups.getByName('newColors');
var allColors = colorSwatches.getAllSwatches();
var colorNames = Array();
for (var i = 0; i < allColors.length; i++){
colorNames.push(allColors[i].name);
}
for (x = 0; x<colorNames.length; x++)
{
var currentColor = allColors[x].name;
for (i=0; i<iL; i++)
{
var myItem = app.activeDocument.pathItems[i];
if(myItem.selected)
{
myItem.fillColor = app.activeDocument.swatches.getByName(currentColor).color;
}
}
(I then go on to save each one)
When trying to cross over into applescript I have the following so far:
set iL to count every path item of document 1
set colorSwatches to swatchgroup "newColors" of current document
set allColors to get all swatches colorSwatches
set swatchCount to count every item in allColors
repeat with i from 1 to swatchCount
set currentSwatch to item i of allColors
repeat with x from 1 to iL
set myItem to path item i of document 1
here is where I have no idea what I am doing... I can't figure out how to test if an item is selected
i
f myItem's has selected artwork is equal to true then
set fill color of myItem to {swatch:currentSwatch}
end if
end repeat
end repeat
Or better yet is there a way I can select every path item of a layer and change its color that way?
Something like the following:
set fill color of every path item of layer "art" of document 1 to {swatch:currentSwatch}
Thanks for any input!