Is it possible to cycle through brushes (tpls) using a script?


i write script cycle through set of tool presets this:

i run script , selects brush_2 next time run it, selects brush_3 next time run it selects brush_1 again , on, looping forever, each time run script.

 

i imagine done script if update variable each time run (select tool preset brush_x, add 1 x unless x>2 x=1)

but variable x have in memory, outside of script...is such thing possible or variables reset each time run script?

 

thanks!

i have seem brush tool options shown on photoshop tool option bar scripted tom.  can change brushes in script selecting tool presets. want do. script have list of presets cycle through.   there ways have variables outside script. have use 2 different ways , sure there more.  think read use kind of photoshop.option can script.   if need global variable can use system environment  variable. if search on toggle  brush hit code uses  environment variable. if need variables associated documents working on can use document metadata.  use documents instructions metadata fields that.

 

they can use toggle , storing data. here 1 use metadata.  cc 2015.5 has new bug may not set metadata field empty.  not use cc 2015.5 bugs breaks several of scripts..  easy program around need in metadata field x marks spot.  adobe working on fix.

 

/* ====================================================================================== // 2009  john j. mcassey (jjmack)  http://www.mouseprints.net/ //   // script supplied is. provided freeware.  // author accepts no liability problems arising use. // // script designed used photoshop action twice // pratice use when creating actions use scipt action  // not save or play other action between 2 useages of script. //  // first time script used action documents current resolution // , ruler units saved document's meta-data info instructions field. // // second time script used action script retreives // saved in meta-data during first usage, resolution , ruler units. // document resized saved resolution, // photoshop's ruler units set saved units // , saved data removed document's meta-data info instructions field. // // ===================================================================================== */   /* <javascriptresource> <about>$$$/javascripts/saveandrestoreresolution/about=jjmack's saveandrestoreresolution.^r^rcopyright 2009 mouseprints.^r^rrun twice script utility action.^rnote:don't play other actions between runs!^r^rfirst run records photoshop's preferences units , documents dpi resolution.^rsecond run restores recorded setting , removes recording.</about> <category>jjmack's action run twice utility</category> </javascriptresource> */   if (app.documents.length > 0) {    if (app.activedocument.info.instructions.indexof("<resolution>") == -1 ){ // no footprint fisrt useage    //alert("first");   // retreive document information foot print                  var units = app.preferences.rulerunits;   app.preferences.rulerunits = units.pixels; // set ruler units pixels                 var typeunits = app.preferences.typeunits;   var res = app.activedocument.resolution;      // put footprint in metadata info instructions   app.activedocument.info.instructions = app.activedocument.info.instructions + "<units>" + units + "</units>"  + "<tunits>" + typeunits + "</tunits>" + "<resolution>" + res + "</resolution>";    //alert( "saved ="  + "<units>" + units + "</units>" + "<tunits>" + typeunits + "</tunits>" + "<resolution>" + res + "</resolution>" );      app.preferences.rulerunits = units; // restore ruler units   }    else {    //alert("second");     // retreive saved information   unitsoffset = app.activedocument.info.instructions.indexof("<units>") + "<units>".length;   unitslength = app.activedocument.info.instructions.indexof("</units>") -unitsoffset;   savedunits = app.activedocument.info.instructions.substr(unitsoffset, unitslength);     tunitsoffset = app.activedocument.info.instructions.indexof("<tunits>") + "<tunits>".length;   tunitslength = app.activedocument.info.instructions.indexof("</tunits>") -tunitsoffset;   savedtunits = app.activedocument.info.instructions.substr(tunitsoffset, tunitslength);     resoffset = app.activedocument.info.instructions.indexof("<resolution>") + "<resolution>".length;   reslength = app.activedocument.info.instructions.indexof("</resolution>") + -resoffset;   savedresolution = app.activedocument.info.instructions.substr(resoffset, reslength);   //alert("resolution = " + savedresolution + " units = " + savedunits );     // restore resolution   app.preferences.rulerunits = units.pixels;   activedocument.resizeimage(null, null, savedresolution, resamplemethod.none);     // restore ruler units    // message enumerated value expected if try use var savedunits app.preferences.rulerunits = savedunits;   // perhaps if knew javascript not need use following if else if .....    if ( savedunits == "units.inches" ){ app.preferences.rulerunits = units.inches;}   else if ( savedunits == "units.cm" ){ app.preferences.rulerunits = units.cm;}   else if ( savedunits == "units.percent" ){ app.preferences.rulerunits = units.percent;}   else if ( savedunits == "units.mm" ){ app.preferences.rulerunits = units.mm;}   else if ( savedunits == "units.pixels" ){ app.preferences.rulerunits = units.pixels;}   else if ( savedunits == "units.points" ){ app.preferences.rulerunits = units.points;}   else if ( savedunits == "units.picas" ){ app.preferences.rulerunits = units.picas;}     // restore type units    if ( savedtunits == "typeunits.pixels" ){ app.preferences.typeunits = typeunits.pixels;}   else if ( savedtunits == "typeunits.points" ){ app.preferences.typeunits = typeunits.points;}   else if ( savedtunits == "typeunits.mm" ){ app.preferences.typeunits = typeunits.mm;}      // remove footprint metadata info instructions   before = app.activedocument.info.instructions.substr(0,app.activedocument.info.instructions.indexof("<units>"));   afteroffset = app.activedocument.info.instructions.indexof("</resolution>") + "</resolution>".length;   after = app.activedocument.info.instructions.substr(afteroffset, app.activedocument.info.instructions.length - afteroffset);   //alert ("before = " + before + " after = " + after);   app.activedocument.info.instructions = before + after;   }  }  else { alert("you must have @ least 1 open document run script!"); }  


More discussions in Photoshop 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