Have problems assigning fill color via script
I am having a bear of a time changing the fill color of a polygon object. The polygon object has a name of "Ribbon". Here is the code I am using to try and change it along with the errors I receive in the comments:
var gDoc = app.activeDocument;
var myPages = gDoc.pages;
myGroupItems = myPages[0].allPageItems;
if (gDoc.pageItems.item("Ribbon").isValid) {
gDoc.pageItems.item("Ribbon").fillColor = templateDoc.colors.item("myTabColor").colorValue; // Invalid value for set property 'fillColor'. Expected Swatch or String, but received (34, 0, 9, 0).
gDoc.pageItems.item("Ribbon").fillColor = templateDoc.colors.item("myTabColor") // Invalid value for set property 'fillColor'. Expected Swatch or String, but received Color
gDoc.pageItems.item("Ribbon").fillColor = templateDoc.swatches.item("myTabColor"); // Invalid value for set property 'fillColor'. Expected Swatch or String, but received Color.
}
On the command line of the debugger I tried the following:
templateDoc.swatches.item("myTabColor")
[object Swatch]
templateDoc.swatches.item("myTabColor").isValid
true
So you can see that templateDoc.swatches.item("myTabColor") returns a swatch object.
So why does gDoc.pageItems.item("Ribbon").fillColor = templateDoc.swatches.item("myTabColor"); not work if I am assigning a swatch value?
I have tried so many different variations and none have worked. I never thought it would be this hard to change the color of a polygon. 🙂
Thank you in advance for any help provided.
