• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

how to change both fill color and stroke color

New Here ,
Mar 08, 2017 Mar 08, 2017

Copy link to clipboard

Copied

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=rectsarr.filled=false;

        rectsarr=rectsarr.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!

TOPICS
Scripting

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Mar 09, 2017 Mar 09, 2017

Hi, line 35

rectsarr=rectsarr.filled=false;

is equivalent to

rectsarr.filled=false;

rectsarr=false;

so that line 36 will become

false = false.strokeColor = newCMYKColor;

Of cause that will make no sense.

So please change line 35&36 to:

rectsarr.filled=false; 

rectsarr.strokeColor=newCMYKColor; 

Votes

Translate

Translate
Adobe
Enthusiast ,
Mar 09, 2017 Mar 09, 2017

Copy link to clipboard

Copied

Hi, line 35

rectsarr=rectsarr.filled=false;

is equivalent to

rectsarr.filled=false;

rectsarr=false;

so that line 36 will become

false = false.strokeColor = newCMYKColor;

Of cause that will make no sense.

So please change line 35&36 to:

rectsarr.filled=false; 

rectsarr.strokeColor=newCMYKColor; 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 09, 2017 Mar 09, 2017

Copy link to clipboard

Copied

LATEST

thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines