Quantcast
Channel: Adobe Community : Discussion List - Illustrator Scripting
Viewing all articles
Browse latest Browse all 3671

how to change both fill color and stroke color

$
0
0

hello guys,

i'm new to JS , i'm trying to write a script that can create some rectangle and put them in right places. it will create dieline for shippers.

and,here is my code

var mm =2.834645669291;
var doc = app.activeDocument;
var title = "Jason Li's 大箱脚本"; 
var LeftBar = Number(prompt ("是否有左侧粘贴条 0为无,如有请输入尺寸",0, title))*mm;
var length = Number(prompt ("输入长度",0, title))*mm;
var width = Number(prompt ("输入宽度",0, title))*mm;
var height = Number(prompt ("输入高度",0, title))*mm;
var copyvalue = length+width;
var rect = doc.pathItems;
    var noColor=new NoColor();    newCMYKColor = new CMYKColor();    newCMYKColor.black = 100;    newCMYKColor.cyan = 0;    newCMYKColor.magenta = 0;    newCMYKColor.yellow = 0;
newGroup = app.activeDocument.groupItems.add();
newGroup.name = "Dieline";
var DielineLayer = doc.activeLayer;    DielineLayer.name = "Dieline";
var rectsarr=new Array()
rectsarr[0] = rect.rectangle(0,0,length,height);
rectsarr[1] = rect.rectangle(0,length,width,height);
rectsarr[2] = rect.rectangle(width/2,0,length,width/2);
rectsarr[3] = rect.rectangle(width/2,length,width,width/2);
rectsarr[4] = rect.rectangle(-height,0,length,width/2);
rectsarr[5] = rect.rectangle(-height,length,width,width/2);
rectsarr[6] = rect.rectangle(0,copyvalue,length,height);
rectsarr[7] = rect.rectangle(0,length+copyvalue,width,height);
rectsarr[8] = rect.rectangle(width/2,copyvalue,length,width/2);
rectsarr[9] = rect.rectangle(width/2,length+copyvalue,width,width/2);
rectsarr[10] = rect.rectangle(-height,copyvalue,length,width/2);
rectsarr[11] = rect.rectangle(-height,length+copyvalue,width,width/2);
if(LeftBar>0){rectsarr[12] = rect.rectangle(0,-LeftBar,LeftBar,height);}
for (i=0;i<rectsarr.length;i++){        rectsarr[i]=rectsarr[i].filled=false;        rectsarr[i]=rectsarr[i].strokeColor=newCMYKColor;    }

i'm changing the fillcolor to none( line 35) , it works , but at line 36 , i want to change the strokecolor , and it doesn't work.

BUT, if i delete or put line 35 below line 36 , the strokecolor will be change but fill color remain filled. very very weird. so i think i missed something .

please help me ! thanks!


Viewing all articles
Browse latest Browse all 3671


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>