How to apply fillColor tint?


hello – script reads csv file (which holds path names , corresponding tint values) , tries apply tint each named path. paths have been filled 100% of spot color.

 

the script (below) builds on muppet mark generously supplied else's question while back. works fine if change opacity of objects, not if change tints. can please show i'm doing wrong?

 

many thanks.

 

#target illustrator 

applydatafile(); 

function applydatafile() { 

          if ( app.documents.length == 0 ) { return; } 

          var doc, csvfile, i, filearray; 

          csvfile = file.opendialog("choose csv file");

          if ( !csvfile.exists ) { return; } 

          filearray = readincsv( csvfile ); 

          doc = app.activedocument; 

   

          // each line of data file...

          ( = 0; < filearray.length; i++ ) { 

   

          // ...get named path [i][0] , give property value [i][1]

          // works: doc.pathitems.getbyname( filearray[i][0] ).opacity = filearray[i][1];

          // following line has no effect:

          doc.pathitems.getbyname( filearray[i][0] ).fillcolor.tint = filearray[i][1]; 

          };   

}; 

 

function readincsv( fileobj ) { 

          var filearray, thisline, csvarray; 

          filearray =[]; 

          fileobj.open( 'r' ); 

          while( !fileobj.eof ) { 

                    thisline = fileobj.readln(); 

                    csvarray = thisline.split( ',' ); 

                    filearray.push( csvarray ); 

          }; 

          fileobj.close(); 

          return filearray; 

};

 

csv file contents:

 

one,35

two,55

three,75

four,95

 

message edited by: david entwistle aid clarity.

hi david_entwistle

how this?

applydatafile();   function applydatafile() {     if ( app.documents.length == 0 ) { return; }     var doc, csvfile, i, filearray, pi;     csvfile = file.opendialog("choose csv file");     if ( !csvfile.exists ) { return; }     filearray = readincsv( csvfile );     doc = app.activedocument;     // each line of data file...     ( = 0; < filearray.length; i++ ) {         pi = doc.pathitems.getbyname( filearray[i][0] );         if (pi.fillcolor.tint == 100) { // change if tint value == 100         pi.fillcolor.tint = pi.fillcolor.tint *(filearray[i][1]/100);         }     } }  function readincsv( fileobj ) {           var filearray, thisline, csvarray;           filearray =[];           fileobj.open( 'r' );           while( !fileobj.eof ) {                     thisline = fileobj.readln();                     csvarray = thisline.split( ',' );                     filearray.push( csvarray );           }                     $.writeln (filearray);           fileobj.close();           return filearray; } 

 

have fun

 



More discussions in Illustrator Scripting


adobe

Comments

Popular posts from this blog

Reader DC

AdobeIDの作り方

Adobe InDesign CC 2017 has stopped working