Changing the strokeWidth using strokeColor


i'm new javascript, , i'm having difficulty.  i've got existing knowledge of python, i've found it's rather different.  i'm trying figure out how change stroke width path based on it's color.  there simplified version of script below.

 

for reason never recognizes color of path.  i've tried comparing color class created stroke color, never works.  i've tried doing comparison of different rgb components of color, gives me error.  if add path.strokecolor.rgbcolor.red error saying "undefined not object". 

 

the rgb color class should have red component, right?  don't understand why it's undefined.

 

does have thoughts?

 

if (documents.length > 0 && activedocument.pathitems.length > 0){   // gets paths in document   var allpaths = activedocument.pathitems;    // color want find, red   var red = new rgbcolor();   red.red = 233;   red.green = 38;   red.blue = 41;    // change stroke of path if it's red line   (var l=0; l < allpaths.length; l++) {    // select red paths   if (allpaths[l].strokecolor.rgbcolor.red == red.red) {   allpaths[l].strokewidth = 10.0;   }   } } 

in case of javascript, "rgbcolor" is actually "strokecolor".

so can do:

if (allpaths[l].strokecolor.red == red.red) { 



More discussions in Illustrator Scripting


adobe

Comments

Popular posts from this blog

Illustrator CS6 Ocurrío un error E/S en el archivo.

Why is os_ViewContainer running?

Animate - problem with duplicating scripts after loop