update the textframes automatically?


here, i'm pasted code, displays artboard name in central of each artboard in document customized format. want improvise if update artboard name printed artboard name should replaced new 1 or can updated without forming new textframe on previous textframe. please improvise code.

 

// code does? //this script takes document's name , artboard names , prints them central of each artboard in customized format      app.coordinatesystem = coordinatesystem.artboardcoordinatesystem; var mydocument = app.activedocument;        // creates label each artboard      (var = 0; < app.activedocument.artboards.length; i++)   {                var artboard = app.activedocument.artboards[i];           //alert("text frames ==> ", artboard.textframes);            // each artboard, add new text frame                            // make area type instead of point type                      //var pointtextref = app.activedocument.textframes.add();                           // print file prefix         var dnam = app.activedocument.name;         // finds _ @ underscore in document name , prints upto there         var fx  = dnam.indexof("_");         var pfx = dnam.substring(0,fx);                              // print file artboard number         var anam = artboard.name;         var afx  = anam.indexof(" ");         var apfx = anam.substring(8,12);                  //alert("--"+mylabel.contents+"++");         //alert("q--"+mylabel.contents+"|||||"+mylabel.contents !== ""+";;;");                  // fill artboard name           var mylabel = mydocument.textframes.add();          if (mylabel.contents === "") {              // print file name              mylabel.contents = pfx+":"+apfx;           }          else {             //mylabel.remove();                  }                  // rectangle(height,0,50,20);         var fontstyle = mylabel.textrange.characterattributes;         fontstyle.fillcolor = makecolor(0,0,0);         fontstyle.textfont = app.textfonts.getbyname("impact");         fontstyle.strokecolor = makecolor(255,255,255);         fontstyle.strokeweight = 0.4;         fontstyle.tracking = 10;         fontstyle.size = 18;           mylabel.opacity = 80;                  // necessary since rgbcolor class has no constructor.                    function makecolor(r,g,b){             var c = new rgbcolor();             c.red   = r;             c.green = g;             c.blue  = b;             return c;            }            /*this line controls font size           mylabel.textrange.characterattributes.size = 16   ;            var rec = artboard.artboardrect[0];         var rec1= artboard.artboardrect[1];         var rec2 = artboard.artboardrect[2];         var rec3 = artboard.artboardrect[3];           alert(rec);         alert(rec1);         alert(rec2);         alert(rec3);  */                  // position of watermark                  mylabel.position = [[artboard.artboardrect[2]+artboard.artboardrect[0]]/2, [artboard.artboardrect[1]+artboard.artboardrect[3]]/2];                                  }   

 

if run script first time. display shown in screenshot. 

  

after adding new artboard document , running script it's forming new textframe on previoud text frames. don't want happen.. should updated or replaced.

in code (if script runs) adds textframe.

and if clause in line 40 prevent update.

 

check existing textframe unique name (or note). if exists, update contents, if not exists create text frame unique name (or note)



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