Script with magic wand


i noticed there's no documentaion on scripting (javascript) magic wand selection. i'd assume it's along lines of magicwand.(x,y).tolerance.contigious.true.samplealllayers.true. or that. it's guess work.

 

var id176 = charidtotypeid( "setd" );
    var desc34 = new actiondescriptor();
    var id177 = charidtotypeid( "null" );
        var ref15 = new actionreference();
        var id178 = charidtotypeid( "chnl" );
        var id179 = charidtotypeid( "fsel" );
        ref15.putproperty( id178, id179 );
    desc34.putreference( id177, ref15 );
    var id180 = charidtotypeid( "t   " );
        var desc35 = new actiondescriptor();
        var id181 = charidtotypeid( "hrzn" );
        var id182 = charidtotypeid( "#pxl" );
        desc35.putunitdouble( id181, id182, 0.000000 );
        var id183 = charidtotypeid( "vrtc" );
        var id184 = charidtotypeid( "#pxl" );
        desc35.putunitdouble( id183, id184, 0.000000 );
    var id185 = charidtotypeid( "pnt " );
    desc34.putobject( id180, id185, desc35 );
    var id186 = charidtotypeid( "tlrn" );
    desc34.putinteger( id186, 32 );
    var id187 = charidtotypeid( "mrgd" );
    desc34.putboolean( id187, true );
    var id188 = charidtotypeid( "anta" );
    desc34.putboolean( id188, true );
executeaction( id176, desc34, dialogmodes.no );

 

 

i've got above old script listener , trying tidy (and learn bit in process)

 

cheers

this 1 of things can scriptlistener. here 1 way clean code.

function magicwand(x,y,t,a,c,s) {     if(arguments.length < 2) return;// make sure have x,y     if(undefined == t) var t = 32;// set defaults of optional arguments     if(undefined == a) var = true;     if(undefined == c) var c = false;      if(undefined == s) var s = false;     var desc = new actiondescriptor();         var ref = new actionreference();         ref.putproperty( charidtotypeid('chnl'), charidtotypeid('fsel') );     desc.putreference( charidtotypeid('null'), ref );         var positiondesc = new actiondescriptor();         positiondesc.putunitdouble( charidtotypeid('hrzn'), charidtotypeid('#rlt'), x );// in pixels         positiondesc.putunitdouble( charidtotypeid('vrtc'), charidtotypeid('#rlt'), y );     desc.putobject( charidtotypeid('t   '), charidtotypeid('pnt '), positiondesc );     desc.putinteger( charidtotypeid('tlrn'), t);// tolerance     desc.putboolean( charidtotypeid('mrgd'), s );// sample layers     if(!c) desc.putboolean( charidtotypeid( "cntg" ), false );//  contiguous     desc.putboolean( charidtotypeid('anta'), );// anti-alias     executeaction( charidtotypeid('setd'), desc, dialogmodes.no ); }; 

you clean more adding data type checks arguments.



More discussions in Photoshop Scripting


adobe

Comments

Popular posts from this blog

CS5 Adobe Media Encoder: Encode failed because the source duration is nil.

cf_sql_integer vs cf_sql_bigint vs cf_sql_int??

localhost/joomla15/administrator doesnt work - Joomla! Forum - community, help and support